Archived topic
Feature image size not at set in theme
3 replies · Started by Sam on June 11, 2022
Hi
Just noticed something strange when reviewing my site scheme
Despite my features images physically being 1200px and the GP Post image Size set to full - my schema is reporting they are 840px, which does not match nay of my default image sizes
I am not sure why - and where and what i need to do to correct
I will point out that I have the following snippet to swap out the image for a smaller size on mobile (768px)
add_action( 'wp_head', function() {
if( is_single() ) {
$featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'medium_large');
$featured_img_url_full = get_the_post_thumbnail_url(get_the_ID(),'full');
echo '<link rel="preload" media="(max-width: 768px)" as="image" href="'.$featured_img_url.'"/>';
echo '<link rel="preload" media="(min-width: 769px)" as="image" href="'.$featured_img_url_full.'"/>';
echo '<style>
.page-hero {
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
}
@media(max-width: 768px) {
.page-hero { background-image: url('.$featured_img_url .');}
}
@media(min-width: 769px) {
.page-hero { background-image: url('.$featured_img_url_full .');}
}
</style>';
}
},1000);
I have added link to my staging site below (as my live does not yet have that schema value assigned yet)
Thanks
S
Hi there,
how are you adding the JSON-lD Schema to the site ?
I using the SEOPress Pro plug-in which automatically adds Article schema to my blog posts
I am currently reviewing all of my site set-up after the recent core update - I got a bit of kicking.
I just happen to notice that the feature image dims being reported in schema where different from the physical size - as most, if not all, should be 1200px. Which I understand to be google's preferred size to in order feature in the discovery feed.
Check with SEO Press on where its getting the size from.
I assume the plugin would scrape the content for the image, and gets its size from there. In your case you're not displaying an <img> in the content so it may be grabbing a default width value from somewhere.