0

I've added the following code to my theme's functions.php file:

function add_custom_sizes() {
    add_image_size('featured-thumbnail', 690, 500, true);
    add_image_size('secondary-thumbnail', 460, 236, true);
    add_image_size('related-thumbnail', 360, 262, true);
    add_image_size('true-thumbnail', 337, 209, true);
    add_image_size('search-thumbnail', 208, 130, true);
}
add_action('after_setup_theme', add_custom_sizes);

Within my template I have code such as:

<?php
      if (has_post_thumbnail() ) {
        the_post_thumbnail('featured-thumbnail');
      } else { ?>
        <img src="http://via.placeholder.com/690x500" alt="">
<?php } ?>

And this is the image it outputs:

<img width="690" height="407" src="https://s3.amazonaws.com/.../image-2440x1440.jpg" class="attachment-featured-thumbnail size-featured-thumbnail wp-post-image" alt="" />

The original size of the image is 2440px x 1440px so I don't understand why it's not respecting my height category. It's a brand new image that's been uploaded, but just to double check I've regenerated my thumbnails but the problem persists. I'm at a complete loss. I literally just banged my head against my desk.

0

There are 2 things in your case to consider:

  1. Your link contains s3.amazonaws.com... - this means that your site might be using a cdn. Are you completely sure that it is configureв and working as intended?
  2. I just reviewed my code and I don't hook add_image_size inside functions.php to any action. Could you try to unhook your code? This might work!
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.