This commit is contained in:
2024-06-16 20:33:37 +03:00
parent 5896a8d1c6
commit d7584deff0
3 changed files with 60 additions and 0 deletions

View File

@@ -988,3 +988,17 @@ function adddr_hash(){
}
// Пример замены изображений на AMP-изображения в контенте поста
function convert_images_to_amp($content) {
if (function_exists('is_amp_endpoint') && is_amp_endpoint()) {
$content = preg_replace(
'/<img(.*?)src="(.*?)"(.*?)>/i',
'<amp-img$1src="$2"$3 layout="responsive" width="600" height="400"></amp-img>',
$content
);
}
return $content;
}
add_filter('the_content', 'convert_images_to_amp');