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 ...
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 ...
7
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/...
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....
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('...
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].'">';
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 ...
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',...
4
votes
How to set thumbnail image for a (child) theme
What Vinod Dalvi said, except:
Make sure the file is named using all lower case:
screenshot.png
or
screenshot.jpg.
screenshot.PNG won't work!
3
votes
Featured image on post edit page not loading over HTTPS
It turned out to be a problem with the uploads directory (not sure what caused it initially). I was able to resolve the issue with the following filter:
function fix_ssl( $url ) {
if ( is_ssl() ) ...
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', ...
3
votes
Accepted
Is there a way to change a post's thumbnail image(s)?
Facebook scrapes your pages for images to go along with the post you share. When it finds an image on the page it will use that.
To specify which image exactly you have to use Open Graph tags in the ...
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 ...
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 ...
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 ...
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 ...
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|...
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->...
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[...
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 ...
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.
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['...
2
votes
Accepted
Can't get post thumbnail to display in foreach loop
If you read the documentation that you have linked to, you would see that the post ID is stored in the array key post_id and not ID.
You should then change
get_the_post_thumbnail($popular_post->...
2
votes
Accepted
Lazyload post thumbnails
You got everything you need, simply build your own img-element like this:
if ( has_post_thumbnail() ) {
$class = 'lazy attachment-thumbnail-400-300';
//Get thumbnail source
$thumb = ...
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 ...
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 ...
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 = ...
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
thumbnails × 401images × 144
post-thumbnails × 135
uploads × 26
plugins × 24
php × 24
woocommerce-offtopic × 23
media × 22
media-library × 18
gallery × 18
categories × 17
attachments × 15
custom-post-types × 12
functions × 11
customization × 11
cropping × 11
theme-development × 9
plugin-development × 8
posts × 7
loop × 6
themes × 6
wp-query × 5
custom-field × 5
filters × 5
shortcode × 5