You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We’ve received a report from a customer saying that they are using the wpseo_opengraph_image_size filter to select a specific image size for their og: images. However, this causes the og:image tag not to be added to the page.
The customer is using the following filter:
// Add custom image size for Yoast SEO socials
add_image_size( 'featured-full', 1200, 800 );
add_filter( 'wpseo_opengraph_image_size', 'yoast_seo_opengraph_change_image_size' );
function yoast_seo_opengraph_change_image_size() {
return 'featured-full';
}
A similar issue was previously reported here: twitter:image not being output at all, and og:image tag is ignoring wpseo_opengraph_image_size filterWAIT FOR FEEDBACK
More details from the user:
In WPSEO_Image_Utils::get_image, image_get_intermediate_size method returns the image array for the particular size. But in case there's no image for that size, which can happen in 2 cases:
the image is too small
the image is the same size as the size being asked for.
My case is the latter. So the size does exist but since the original file is the same as the size setting, no additional file has been created. eg.
In the above case, image_get_intermediate_size( $id, 'featured-full') return false! And hence no image is returned to g:image!
The customer has also added some workarounds they have implemented manually in the plugin core to fix this issue:
FTI, this is the hack I added to your code that helped resolve this issue for me (this is not added to the above server though so you can test properly):
FTI, this is the hack I added to your code that helped resolve this issue for me (this is not added to the above server though so you can test properly):
public static function get_image( $attachment_id, $size ) {
$image = false;
if ( $size === 'full' ) {
$image = self::get_full_size_image_data( $attachment_id );
}
The customer has lots more details in HelpScout ticket number 869467
The text was updated successfully, but these errors were encountered:
BobBreukhoven
changed the title
Improve link in schema metabox, depending on the Post Type
Using the wpseo_opengraph_image_size filter to select a specific image size does not output an og:image tag.
Dec 21, 2022
https://yoast.atlassian.net/browse/DUPP-857
It’s a popular issue based on the number if bug reports we have received so far from many different users. I made a complete list for you:
wpseo_opengraph_image_size
custom size is ignored once post is saved inwp_yoast_indexable
table (since 16.2)COMPONENT: OPENGRAPHIM-2033: wpseo_opengraph_image should run (even) if there's no image setNEW
wpseo_opengraph_image_size
custom size is ignored once post is saved inwp_yoast_indexable
table (since 16.2)COMPONENT: OPENGRAPHIssues with custom FB image sizes & og:image tagsCOMPONENT: SOCIAL
Changing the og:image for Custom Post Type archive pagesTYPE: FEATURE REQUEST
Not always able to use
wpseo_opengraph_image
filter for addingog:image
COMPONENT: HOOKSWe’ve received a report from a customer saying that they are using the wpseo_opengraph_image_size filter to select a specific image size for their og: images. However, this causes the og:image tag not to be added to the page.
The customer is using the following filter:
// Add custom image size for Yoast SEO socials
add_image_size( 'featured-full', 1200, 800 );
add_filter( 'wpseo_opengraph_image_size', 'yoast_seo_opengraph_change_image_size' );
function yoast_seo_opengraph_change_image_size() {
return 'featured-full';
}
A similar issue was previously reported here:
twitter:image
not being output at all, andog:image
tag is ignoringwpseo_opengraph_image_size
filterWAIT FOR FEEDBACKMore details from the user:
In WPSEO_Image_Utils::get_image, image_get_intermediate_size method returns the image array for the particular size. But in case there's no image for that size, which can happen in 2 cases:
the image is too small
the image is the same size as the size being asked for.
My case is the latter. So the size does exist but since the original file is the same as the size setting, no additional file has been created. eg.
https://insidehook-com-preprod.go-vip.net/wp-content/uploads/2022/02/hero-1.jpeg
Is the same as the required size "featured-full" - 1200x800. Hence no additional image has been created by WP.
In the above case, image_get_intermediate_size( $id, 'featured-full') return false! And hence no image is returned to g:image!
The customer has also added some workarounds they have implemented manually in the plugin core to fix this issue:
FTI, this is the hack I added to your code that helped resolve this issue for me (this is not added to the above server though so you can test properly):
FTI, this is the hack I added to your code that helped resolve this issue for me (this is not added to the above server though so you can test properly):
public static function get_image( $attachment_id, $size ) {
$image = false;
if ( $size === 'full' ) {
$image = self::get_full_size_image_data( $attachment_id );
}
if ( ! $image ) {
$image = image_get_intermediate_size( $attachment_id, $size );
/* THIS HAS BEEN ADDED AS A HACK TO PREVENT LOADING INLINE IMAGE AS OG IMAGE!
/
if ( ! is_array( $image) ) {
$att = wp_get_attachment_image_src( $attachment_id, $size );
$image = array();
$image['url'] = $att[0];
$image['width'] = $att[1];
$image['height'] = $att[2];
}
$image['size'] = $size;
/ END HACK */
}
if ( ! $image ) {
return false;
}
$image['size'] = $size;
return self::get_data( $image, $attachment_id );
The customer has lots more details in HelpScout ticket number 869467
The text was updated successfully, but these errors were encountered: