Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaks Yoast SEO og:image #17

Open
cyrillbolliger opened this issue Jan 18, 2019 · 5 comments
Open

Breaks Yoast SEO og:image #17

cyrillbolliger opened this issue Jan 18, 2019 · 5 comments

Comments

@cyrillbolliger
Copy link

Issue
The removal of the image sizes automatically generated when uploading an image done here makes the wordpress function image_get_intermediate_size() always return the full size image. However, if the full size image is wider or higher than 2000px, Yoast SEO rejects it as an og:image. It would therefore be great, if the image size large would not be cleared out. Or the function would at least have a filter.

Yoast SEO uses the image_get_intermediate_size() function here.

How to reproduce it
Prerequisites: WordPress with Theme that uses Timmy and the Yoast SEO Plugin.

Create a post, navigate to the social section of Yoast SEO metabox and add a facebook image that is wider than 2000px. Visit the post (frontend) and inspect the source code. The meta property og:image is missing.

Then change the image to one that is smaller than 200px wide and inspect the source code again -> the meta property og:image is now here.

@gchtr
Copy link
Member

gchtr commented Jan 18, 2019

Hey @cyrillbolliger

Yeah, I ran into the same issue. The issue is not only that there’s no large image size, it’s also that Yoast grabs the data from the metadata of an image, which is usually saved in the database.

With Timmy v14.0, Timmy will generate that image metadata just like it would for default WordPress images. So, to make it work, you have to:

  1. Define a large image size in your image configuration for Timmy.

    'large' => array(
        'resize'     => array( 1400 ),
        'show_in_ui' => false,
    ),
  2. Run Regenerate Thumbnails to generate the image metadata for the database.

@cyrillbolliger
Copy link
Author

cyrillbolliger commented Jan 18, 2019

Hi @gchtr

Thanks for your lightning fast response. I just tested your proposed solution: It works if I regenerate the thumbnail. However if I upload a new image, it doesn't solve the problem. I still have to regenerate the thumbnail after uploading a new image in order to get it working.

Grüess uf Winti ;)

@cyrillbolliger
Copy link
Author

Hi @gchtr

I found a workaround meanwhile, I'll post it here in case it helps someone else. It basically just adds the size 'large' again:

add_filter( 'intermediate_image_sizes_advanced', function ( $metadata ) {
	$metadata['large'] = array(
		'width'  => 1200, // some value that comforts facebook etc.
		'height' => 0,
		'crop'   => false,
	);
	
	return $metadata;
}, 11 );

@gchtr
Copy link
Member

gchtr commented Jan 22, 2019

Hey @cyrillbolliger

That’s a cool little workaround! Small note for myself and others: Using the intermediate_image_sizes_advanced will use the default WordPress image resizing functionality instead of Timmy’s.

However if I upload a new image, it doesn't solve the problem. I still have to regenerate the thumbnail after uploading a new image in order to get it working.

That’s strange! I just tested it, and when I drop an image in the Media menu in the backend, the meta data is generated.

Timmy returns an empty array for intermediate_image_sizes_advanced to prevent running the default image generation of WordPress. This is for performance reasons. That filter is called in wp_generate_attachment_metadata(), which later also calls the wp_generate_attachment_metadata filter, where Timmy builds up the sizes array for the meta data.

So I have two questions for you:

  1. Where do you upload the image?
  2. Can you check whether another plugin might interfere by disabling all other plugins and try it again?

Thinking of this, I could probably use the wp_get_attachment_metadata filter to generate the sizes array for the meta data on the fly, if it’s not present 🤔.

Liebi Grüess zrugg nach Bern 🇨🇭🙌

@cyrillbolliger
Copy link
Author

cyrillbolliger commented Sep 30, 2019

Gosh, I completely forgot this issue, I'm very sorry! As you edited the last response, it reappeared in my feed...

Where do you upload the image?

It works, if I upload the image as content image. However if I upload it in the social section of Yoast SEO metabox as facebook image, it doesn't. Neither if I upload it in the media library (if the Image isn't linked in the content elsewhere).

Can you check whether another plugin might interfere by disabling all other plugins and try it again?

I tried to disable all except ACF and Yoast SEO, but it didn't make a difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants