I’m looking to run through my content variable and replace all
<amp-img width="" height="" where I use getimagesize to find the width and heights for each image.
I have this code to get the size attributes, but I’m not sure how to use preg_replace to replace each image with its own attributes?
$my_image = array_values(getimagesize('test.jpg'));
//use list on new array
list($width, $height, $type, $attr) = $my_image;
Thanks for any help!
Hi @Mohammed and welcome to the forum.
The link you supplied only replaces the amp-img tag and does not insert the image width or height dimensions.
I have temporarily removed the amp-img tags on one of my sites because not only are width and height explicitly required, it is also necessary to remove all inline style references.
Google removed over 500 offending pages from their search and even though the pages no longer have the amp-img references I do not know when Google will include the revised pages. I can see no way to simply re-instate the pages and marking the errors as cleared
Thanks, this was great!
Re image width/height, I am only working with one size so have hard coded a replace to add these
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.