add amp
This commit is contained in:
@@ -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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user