ループ内で実行できること:
<img src="image.jpg" alt="<?php echo get_the_title();?>">
またはカスタムフィールドを使用:
<img src="<?php echo get_post_meta(get_the_ID(), "yourCustomFieldName", true);?>" alt="<?php the_title();?>">
特定のケースでは、最後の閉じ括弧を削除してから、altプロパティを追加できます。
<?php
$From = substr(trim($From),0,-1); //cut the last char
$From .= ' alt="'.get_the_title().'">'; //append the title
?>
または、古いタイプのカスタムフィールドの場合はURLを抽出しますが、新しいタイプのカスタムフィールド(単なるURL)には触れないでください。
if(substr(trim($From),0,5) == '<img '){ //is this an img tag i see?
$boom = explode('"', $From, 3); //it is, aim for the quotes
$From = $boom[1]; //salvage the url
}
次に、そこからimgタグを再構築します。古い形式が次のものと異なる場合は、explode()を確認することをお勧めします。
<img src="xxxxxx">