Featured Image resize
-
I’m having a problem with resizing of my featured image. I’m uploading a picture 1000×667, using that picture in my blog post and also setting it as my featured image. Then on my home page, it cuts off the top and bottom. Its only doing this on some and not others. Any ideas?
Home page: foodieo.net
notice how the main picture is cropped off compared to this one:
http://foodieo.net/apple-stuffed-acorn-squash/
-
Hi gsteinbrenner. Welcome to the Hueman forum. Let me preface this by saying I am not a WP expert nor do I pretend to know everything there is to know about image management in WP. But I’ll try to explain what I think is happening.
When you upload an image to the Media Library the theme uses a “hard crop” to create the following thumbnails:
( ‘thumb-small’ ) 160 x 160
( ‘thumb-standard’ ) 320 x 320
( ‘thumb-medium’ ) 520 x 245
( ‘thumb-large’ ) 720 x 340The theme uses the 720×340 thumbnail for the slider featured image. This is your original 1000×667 image resized to 720px width. The height is then resized proportionately to (720/1000) x 667 = 480px. Since 480px this is larger than the designated thumbnail height, the thumbnail is cropped top and bottom to 340px. When it is displayed the thumbnail is resized using css to 100% of the slider width of 621px and the height is resized proportionately to 293px.
On the home page post the theme is using the 520×245 thumbnail. Again, your original 1000×667 image is resized in width to 520px, and the height is resized proportionately using (520/1000) x 667 = 346px. Since 346px is larger than the designated thumbnail height, the thumbnail is cropped top and bottom to 245px. It is resized for display using css to 100% of the column width of 296px and the height is resized proportionately to 139px.
Your embedded post image is using the full-size image of 1000×667 which is being resized using css to 100% of the content width of 781px; the height is resized proportionately to 521px.
So, how to fix it. One thing you could try is copying the alx_setup() function in functions.php to a child theme functions.php file:
function alx_setup() { // Enable title tag add_theme_support( 'title-tag' ); // Enable automatic feed links add_theme_support( 'automatic-feed-links' ); // Enable featured image add_theme_support( 'post-thumbnails' ); // Enable post format support add_theme_support( 'post-formats', array( 'audio', 'aside', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video' ) ); // Declare WooCommerce support add_theme_support( 'woocommerce' ); // Thumbnail sizes add_image_size( 'thumb-small', 160, 160, true ); add_image_size( 'thumb-standard', 320, 320, true ); add_image_size( 'thumb-medium', 520, 245, true ); add_image_size( 'thumb-large', 720, 340, true ); // Custom menu areas register_nav_menus( array( 'topbar' => 'Topbar', 'header' => 'Header', 'footer' => 'Footer', ) ); }This function contains the theme thumbnail sizes. Change the thumb-medium and thumb-large entries as described in this post. Install and run the Regenerate Thumbnails plugin.
In addition to the theme-generated thumbnails, WP creates four additional thumbnails:
( ‘thumbnail’ ) 150 x 150
( ‘medium’ ) 300 x 300
( ‘large’ ) 640 x 640
( ‘full’ ) original image sizeIf WP can’t create the exact thumbnail size it will try to create something close. What happens if your original image is smaller than the thumbnail sizes? Thumbnails larger than the image aren’t created. If the theme needs a thumbnail that doesn’t exist it uses the ‘full’ size and expands it to fit wherever it goes which, depending on how much it’s expanded, can look really b-a-d.
So, hope that helps. I have links to several other related posts and articles; let me know if you’re interested in more info. I personally think media management is one of the least documented and least understood parts of WP. The user uploads an image and expects that it will fit where it’s supposed to and look right. And when it doesn’t, they say “why not?” and go searching for a fix. On your home page, you would think the post thumbnails should all be the same size, but they’re not. Given everything I said above, why is the “Grilled Marinated Shrimp” post using an uncropped 367×245 thumbnail instead of 520×245? I don’t know the answer. Frustrating for both the user and those of us trying to help, and time consuming for everyone involved. Maybe someday it will be better.
Thanks for the reply. What you say makes a lot of sense, though I’m pretty new to all of this and haven’t used a child theme before. I thought I figured it out but it doesn’t make a difference.
I took a screen shot of what I did and put it here. Does this look right?
That looks correct. Have you tried uploading the image again, with a different name, to see what you get?
Yes, I tried uploading the same picture with a different name, I tried uploading the picture 520*347, I tried changing the code in functions.php and in the child theme.
Any other suggestions?
OK, I’m on to something here. I have a couple pics that show full sized “grilled marinated shrimp”, “puerto rican style beef and cabbage stew” and “fresh tomato meat sauce over zucchini noodles”.
I started a new blog post and tried 1 featured pictures that I knew didn’t work before ( it didn’t work) and then one that worked before (it worked properly). That tells me that its not the thumbnail cropping code and its the pictures. I looked at the details of the pictures that work and the pictures that don’t and I find one unique difference.
On the attachment details page, the “uploaded to” field lists “Media” for the pictures that don’t work. For the pictures that do work, that field has a link to the page of the post its in.
Not sure what that means. Any thoughts?
I think “Media” means it was uploaded to the Media Library. The link to the post means, again I think, that it was uploaded while the post was being edited. So rather than being in the Media Library, it’s actually “attached” to the post. I believe that means that those images are NOT available to use in other posts because you won’t find them in the Library. What happens if you “detach” them? Where do they go? Classic case of trying to give the user more options and make it “easier” to use, and here we are, trying to decipher what it really means. Confusing.
Here are a couple of references but I don’t know that they shed much light on it:
https://codex.wordpress.org/Uploading_Files
https://codex.wordpress.org/Inserting_Images_into_Posts_and_PagesBased on the other references I linked above, and the changes you made, and then regenerated the thumbnails, you would think there ought to be SOME change in the result. Yet there isn’t. And the question is, still, “why not?”
@bdbrown It’s 9 months on and your advice remains invaluable! Thanks for the walk through. I’ve had my problem resolved by just following your steps.
@hoollaa – You’re welcome; glad to help.
The topic ‘Featured Image resize’ is closed to new replies.
