“A value for the image field is required.” AMP Error Solution in WordPress

Image field required error solution amp wordpressNow everyone talking about AMP. Many publishers try AMP on their sites but they tired with full of errors.  Generally, you will wait till Google give AMP error. But there is no need to wait for Google errors, You can self-check what the going on.

How to Check AMP Errors in WordPress :

You have two options to check your AMP errors in your WordPress site. “A value for the image field is required” Error occur then system clearly says that error occurred.

  1. First option is : Google Structured Testing Tool Where you paste your whole URL with amp like www.example.com/postname.html/amp  After that If you have any error in your AMP post page then system shows error with detail like Image A value for the image field is required. Cleck here For Structured Testing tool.
  2. Second Option is : You can also check your AMP errors through Chrome development  console. First type your AMP URL then add  #development=1&filter=AMP_TAG_PROBLEM
    For Example
    www.example.com/postname.html/amp#development=1&filter=AMP_TAG_PROBLEM
    After That Press F12 then go to Consol tab. Here you errors if you have any.

Image Field Required Error Solution AMP :

I want to share some things which are very important to understand AMP process.

  1. AMP Post Always want a Featured Image in Post.
  2. Image size should be more than 700px.

Here two things clear AMP pages always required a featured image. So if you have only 50-60 Post then you can update all the posts with a featured image.

Yeah, i know this is not a solution. Because no one have 50-60 posts. Everyone have 500+ posts so it is quite difficult to impliment.  So,I make an another solution for this.

Now we edit the AMP plugin code where we set if post has featured image then no problem else we add dummy featured image in the post.

Follow below Steps to Edit Plugin Code :

  1. First make a dummy image with 700+px and upload on your server.
  2. Go to Plugin -> Editor (Plugin Editor not theme editor).
  3. Select AMP in Right side top and click on select button.
  4. Open amp/includes/class-amp-post-template.php file.
  5. Make sure you save all the code in notepad for backup purpose.
  6. Find $post_image_src = wp_get_attachment_image_src( $post_image_id, ‘full’ ); .
  7. Paste the below code above the line
    if ( ! $post_image_id ) {
    $post_image_meta = array(
    ‘@type’ => ‘ImageObject’,
    ‘url’ => ‘http://example.com/Techsarjan800-800.png’,
    ‘width’ => ‘800’,
    ‘height’ => ‘800’,
    );
    return $post_image_meta;
    }

All set. Now your “A value for the image field is required” Error solved. Let me know if you have any questions

2 comments

  1. Hello,
    TechSarjan.
    In 7th point, we have to any changes in code, I added my blog home page URL, and post URL, in the place of ‘url’ => ‘http://example.com/Techsarjan800-800.png’, but for me not worked showing unexpected error.

    1. Hi Sidhu,
      Thanks for writing here. Here example.com indicate yourdomainname.com
      So First create an image on paint which size must have 800*800.
      Then upload it to your server. and copy the path of this image.
      Paste in the code URL option.
      Hope it helps.
      Revert back if you face any issue.
      Kind Regards

Leave a Reply

Your email address will not be published. Required fields are marked *