Skip to main content
Share Your Experience: Take the 2024 Developer Survey
8 votes

How To Delete Desired Image Sizes From wp-content/uploads?

That's easy! If you have SSH access, log in and do the following for each size. I am just showing 150x150 size only. Go to the desired uploads folder via command line. cd /your-site.com/wp-content/...
Ahmad Awais's user avatar
8 votes

the_post_thumbnail responsive srcset not populating with custom image size

There's not enough info to be sure this answer is definitive but here's an attempt. Firstly make sure the image you are uploading is actually larger than the size you have defined. I see people ...
Andy Macaulay-Brook's user avatar
8 votes
Accepted

Is there a hook which fires after all thumbnails are generated?

Thumbnails in WordPress can be generated by using wp_generate_attachment_metadata(), this function fires a filter after generating all the thumbnails wp_generate_attachment_metadata and the filter ...
user6552940's user avatar
7 votes

How to Delete All regenerated thumbnails but keep the original ones?

If you use WP-CLI then that will automatically delete those sizes that you don't need. You would run the following command on your server via SSH. You will need to have WP-CLI installed on the server....
grappler's user avatar
  • 845
6 votes

wp_get_attachment_image_src always returns full-sized image

I think this code will help you: $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full', false, '' ); echo '<img src="'.$src[0].'">';
Vidhya Thirugnanam's user avatar
6 votes
Accepted

No srcset for hard-cropped thumbnails

To show a srcset, there must be multiple image sizes of the same aspect ratio. When you set your thumbnail to hard crop without creating any other image sizes you are ensuring that there won't be a ...
Andy Macaulay-Brook's user avatar
6 votes
Accepted

Add version query tag to all images

Don't know why you want to do it when there's update_post_thumbnail_cache() in WordPress and set expire headers on server side. But you can try this in your functions.php: add_filter('...
Minh Tri's user avatar
  • 3,419
5 votes
Accepted

Changing playlist shortcode thumbnail sizes?

Demo Plugin - Fixed Size Here's one suggestion as a demo plugin (PHP 5.4+): <?php /* Plugin Name: Custom Playlist Thumb Size */ namespace WPSE238646\PlaylistThumbSize; add_shortcode( 'playlist',...
birgire's user avatar
  • 67.4k
3 votes

How can i place Feature Image under title field in wp-admin?

Super late to the party, but well... If you want to show your featured image right under the Post title in your Admin area, use this piece of code in your functions.php : add_action('do_meta_boxes', ...
WorkshopforWeb's user avatar
3 votes
Accepted

Regenerate thumbnails for images that are not in the media library

wp-content/uploads images wont regenerate if they are not shown in the Media Library because those media ID's needs to be there in the database.You need to first add your images on the media libray ...
Aishan's user avatar
  • 762
3 votes

get_the_post_thumbnail_url with an unregistered size

WordPress does not create any thumbnail on the fly. If you try to fetch a size that doesn't exist, either the closest size or the full size image will be retrieved. The closest solution you can try ...
Johansson's user avatar
  • 15.3k
3 votes
Accepted

'Post-thumbnails' feature does not seem to register

Image sizes and cropping settings do not apply retroactively: images that were present on your site before you made this change are not affected. Your new settings will only apply to images you ...
Iceable's user avatar
  • 865
3 votes

Image Quality Thumbnail Compression in Wordpress?

(this should be a comment, but my reputation is too low) Setting jpeg_quality will not disable compression because it does not disable processing. JPEGs will be always compressed, and they are almost ...
kubi's user avatar
  • 351
3 votes
Accepted

get_the_post_thumbnail_url('full') returns empty from custom post type

The first argument for that function is not size. See the documentation (if a function's not working, checking the documentation should always be your first step): get_the_post_thumbnail_url( int|...
Jacob Peattie's user avatar
3 votes
Accepted

how to post default thumbnail if post not created yet

Create "images" folder in current active theme the put "dummy-image-1-1.jpg" in that folder. <?php if ($the_query->have_posts() ) : while ($the_query->have_posts()) : $the_query->...
Tanmay Patel's user avatar
3 votes
Accepted

Why are thumbnails not being generated for PDF files?

I found a solution! I hope this helps save some time and frustration for others that might encounter this problem. It turns out that it isn't WordPress or PHP. After a lot of digging, I came across ...
eljefejb's user avatar
  • 631
3 votes
Accepted

How can I add custom sizes for PDF thumbnails generation?

We have the fallback_intermediate_image_sizes filter within wp_generate_attachment_metadata(): ** * Filters the image sizes generated for non-image mime types. * * @since 4.7.0 * * @param string[...
birgire's user avatar
  • 67.4k
2 votes

How to disable WordPress from creating thumbnails?

For the latest WordPress with WooCommerce activated plugin use this code: function add_image_insert_override($sizes){ unset($sizes['thumbnail']); unset($sizes['medium']); unset($sizes['...
Bogdan's user avatar
  • 141
2 votes

Set custom name for generated thumbnails

You could use the filter image_make_intermediate_size, but you would have to figure out what name you want to change the intermediate file to, according to the $filename you get (and then rename the ...
Víctor's user avatar
  • 123
2 votes

Can I attach a document (eg: PDF) but have a JPEG as a thumbnail?

Good news for this old question, since WordPress 4.7, pdf's thumbnail are automatically generated.
Benoti's user avatar
  • 2,436
2 votes
Accepted

related author post thumbnail shows post thumbnail

I think the problem may be that the_post_thumbnail() doesn't accept an ID as a parameter. Instead you should use get_the_post_thumbnail() which does accept an ID as a parameter: <?php echo ...
Stephen S.'s user avatar
  • 1,029
2 votes
Accepted

Store thumbnails and uploads in different directories?

It appears that the thumbnail URLs are generated relatively to the upload folder. So trying to store them outside the uploads folder is not going to be a good idea. There are hacks to filter the ...
Johansson's user avatar
  • 15.3k
2 votes

Detect if image file is a thumbnail

You need to know your site's current thumbnail dimension settings in order for you to detect if the $url is of thumbnail size. $thumbnail_width = get_option( 'thumbnail_size_w' ); $thumbnail_height = ...
Irene Mitchell's user avatar
2 votes
Accepted

How to restrict wp generate attachment metadata() to certain intermediate image sizes

wp_generate_attachment_metadata() uses get_intermediate_image_sizes() to get the sizes to work on, which makes them filterable via intermediate_image_sizes. Additionally, you can filter them after ...
janh's user avatar
  • 2,738
2 votes

What is the best way to change share image for social networks?

This is actually not related to WordPress and applies to any website or blog: When an url is shared for the first time on Facebook, it visits the page to grab the title, image, description, etc. and ...
Iceable's user avatar
  • 865
2 votes

Image Quality Thumbnail Compression in Wordpress?

Uninstall the plugin and add this to your functions.php file add_filter('jpeg_quality', function($arg){return 100;}); add_filter( 'wp_editor_set_quality', function($arg){return 100;} ); However ...
robwatson_dev's user avatar
2 votes

Image Quality Thumbnail Compression in Wordpress?

Make sure you convert your images to sRGB before uploading them to WordPress. Image compression should not dramatically affect the colors and tones of the picture. When you witness a significant ...
Bigue Nique's user avatar
2 votes
Accepted

Media Gallery Upload Thumbnail Compression is Changing Image Hue

That is a huge difference! I think this is your issue... Any time an image is uploaded, if that image was saved in the Adobe RGB color space, then the image does not get loaded correctly for ...
RiddleMeThis's user avatar
  • 3,767
2 votes
Accepted

Show Post Thumbnail In Custom Post From Other CPT

If you want to get the post thumbnail URL, you can use get_the_post_thumbnail_url(): <?php $image_path = 'images/club/' . $opposition->post_name . '.jpg'; // relative to the root directory if ( ...
Sally CJ's user avatar
  • 39.3k
2 votes
Accepted

get taxonomy thumbnail and use it as a variable in code

You have 'taxonomy' => 'product_cat' in your code, so most likely you have Woocommerce, and we need to get a category picture from there. Try this code <?php $args = array( ...
Orbital's user avatar
  • 173

Only top scored, non community-wiki answers of a minimum length are eligible