0

I'm having some issues customizing the thumbnail sizes for featured images.

Attempting to register a custom image size of 860x364, that would be used on a blog post page itself, as well as the list of blog articles. I don't want to replace the thumbnail, however as i use it in other areas.

Code:

if ( function_exists( 'add_theme_support' ) ) {
  add_theme_support( 'post-thumbnails' );
  set_post_thumbnail_size( 860, 364, true ); 
  add_image_size( 'featured-thumb', 860, 364, true ); // 300 pixels wide (and unlimited height)
}

In my single blog post page, calling the image:

<a href="<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full', false ); echo esc_url( $src[0] ); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('featured-thumb'); ?></a>

Does not seem to change anything, what am i doing wrong here. Some strange things with WPRocket inserting picture tags?

HTML:

<a href="http....o.png" title="test">
  <picture class="attachment-featured-thumb size-featured-thumb wp-post-image">
   <source type="image/webp" srcset="https://...ogo.png.webp 900w, https://...167.png.webp 300w" sizes="(max-width: 900px) 100vw, 900px">
   <img width="900" height="500" src="https://...ogo.png" alt="Test" srcset="https://...go.png 900w, https://...167.png 300w" sizes="(max-width: 900px) 100vw, 900px">
  </picture>
 </a>

1 Answer 1

0

Once you created custom size for image you need to regenerate that featured image with plugin if multiple and if only one then remove that image and upload again, so you got cropped image into front.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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