function auto_img_alt( $content ) {
$counter = 1;
$posttitle = get_the_title();
$pattern = '|(<img class="image-icon.*alt=")(.*)(".*\/>)|U';
preg_match_all($pattern,$content,$out);
$count_matches = count($out[2]);
$new_content = preg_replace_callback(
'|(<img class="image-icon.*alt=")(.*)(".*\/>)|U',
function ($matches) use (&$counter, $posttitle, $count_matches){
if($count_matches == '1'){
$matches[2] = $posttitle;
return $matches[1].$matches[2].$matches[3];
}else{
$matches[2] = $posttitle . ', Фото№ ' . $counter;
$counter++;
return $matches[1].$matches[2].$matches[3];
}
},
$content
);
return $new_content;
}
$counter = 1;
$posttitle = get_the_title();
$new_content = preg_replace_callback(
'|(<img class="image-icon.*alt=")(.*)(".*\/>)|U',
function ($matches) use ($counter, $posttitle){
$matches[2] = $posttitle . ', Фото№ ' . $counter;
$counter++;
return $matches[1].$matches[2].$matches[3];
},
$content
);