temandaki functions.php en altına eklersin.
Alıntı
function image_seo($content)
{global $post;preg_match_all('/<img (.*?)\/>/', $content, $images);
if(!is_null($images)) {foreach($images[1] as $index => $value)
{if(!preg_match('/alt=/', $value)){
$new_img = str_replace('<img', '<img alt="'.get_the_title().'"', $images[0][$index]);
$content = str_replace($images[0][$index], $new_img, $content);}}}
return $content;
}
add_filter('the_content', 'image_seo', 70000);
functions.php dosyasına ekleyiniz.
function resim_title_alt_ekle($content) {
global $post;
$baslik = get_the_title($post->ID);
$ara = '/<img(.*?)src="(.*?).(bmp|gif|jpeg|jpg|png)"(.*?)>/i';
$degistir = '<img$1src="$2.$3" title="'.$baslik.'" alt="'.$baslik.'" $4>';
$content = preg_replace( $ara, $degistir, $content );
return $content;
}
add_filter( 'the_content', 'resim_title_alt_ekle' );
Bu kod halihazırda alt ve title tagı girilmiş olanları da değiştiriyor.
Altta benim verdiğim kod alt tagını değiştiriyor eğer girilmemişse. alt="" şeklinde olursa değiştirmiyor ama. onu çözmek lazım.
Ayrıca title tagı eklemiyor. O da çözülürse süper bir şey olur