• Hello. I’m having this warnings in Search Console: “Image size smaller than recommended size”.

    So, I tryed to change it in my functions.php when the image is not a .webp (since I use webp, they have the correct size), but this code is not working:

    add_filter( 'amp_schemaorg_metadata', function( $metadata ) {
    $auxImage = get_the_post_thumbnail_url();
    If (strpos(strtoupper($auxImage),'.WEBP') == 0){
    $post_image_meta = array('@type'=>'ImageObject',
    'url'=>'https://mysite/default.webp',
    'width'=>'1200',
    'height'=>'675');
    $metadata['image'] = $post_image_meta;
    }
    return $metadata;});

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Milind More

    (@milindmore22)

    Hello @roxer82

    Thank you for contacting us, You may be seeing a warning and not the error message, the structured data (schema) of AMP recommends a minimum image with a width of 1200px.

    Primarily the featured image of your post is used in structured data, you will also notice the suggestion notice for the image size (screenshot)

    Your structured data is generated by your SEO plugins such as Yoast SEO, All in one SEO, and other SEO plugins.

    We recommend re-uploading images for posts with the suggested size (images with minimum 1200 width) or contacting your SEO plugin support.

    We hope this helps!

    Thread Starter roxer82

    (@roxer82)

    My news site started in 2007, I have hundred of posts and it would take too long to change it manually. Thats why I need to change it from functions.php for old posts.

    Plugin Support Milind More

    (@milindmore22)

    @roxer82

    Understood, The code snippet you provided seems alright, Can you please share your Support UUID, or link? site, so that we can check if SEO plugin is overwriting the AMP schema

    AMP plugin only adds Schema data when there is none present on AMP pages, which means the filter for AMP schema might not be useful there instead you need to find filter schema from SEO plugin and use it.

    Thread Starter roxer82

    (@roxer82)

    Hi. Yes, this is a site I’m using to test code. In this post the featured image is .jpg (and small), and the code is not changing the featured image.

    https://www.anses.plus/23/imagen-destacada-chica/amp/

    I have not SEO plugin installed yet.

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change featured image’ is closed to new replies.