30

When an image is uploaded in WordPress, it is saved in its original size, and also as some resized copies in different sizes. In this way it becomes easy to use different sizes, of the same image, for different purposes. By default, WordPress creates 3 copies in 3 different sizes: 'thumb' 'medium' 'large' The size in pixels for these 3 sizes can be set in ...


15

Create image file in PNG Format having name screenshot.png and save it in themes root folder.The recommended image size is 880x660. Even recommended image size is 880x660 though it will only be shown as 387x290 but the double-sized image allows for high-resolution viewing on HiDPI displays. For more information see this page. If you don’t already have a ...


14

To built on Max Yudin's answer you should use the intermediate_image_sizes_advanced filter, and not image_size_names_choose. Add to functions.php function add_image_insert_override($sizes){ unset( $sizes['thumbnail']); unset( $sizes['medium']); unset( $sizes['large']); return $sizes; } add_filter('intermediate_image_sizes_advanced', '...


11

You can also filter intermediate_image_sizes with an empty array. add_filter( 'intermediate_image_sizes', '__return_empty_array' );


10

You need to define your arguments before you pass them to WP_Query, not after. Also, your meta_query should be an array of an array, not just an array This $query = new WP_Query($thumbs); $thumbs = array( 'meta_query' => array('key' => '_thumbnail_id') ); should look like this $thumbs = array( 'meta_query' => array( ...


8

A quick and easy fix for this is to make use of a plugin called Force Regenerate Thumbnails (to which I don't have any affiliation to) Unlike a plugin like Regenerating Thumbnails, Force Regenerate Thumbnails creates all your new custom sizes and delete all redundant/orphaned sizes. Force Regenerate Thumbnails allows you to delete all old images size ...


8

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 provides $metadata and $attachment_id to the hooked functions. You can hook your custom function to this filter. $metadata : Attachment metadata. What you need ...


7

This should get you started: Loop over all posts and build an array of linked image files Loop over all image attachments & cross check if any of them have been linked to Might need to batch it or boost the timeout & memory limit, depending on the server & number of posts you're working with. $posts = get_posts( array( '...


7

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/uploads Let's find if that size is available. find ./uploads/* -iname '*-150x150.*' -ls If you see some images as the output then delete 'em with find ./...


6

I have just achieved the effect by my own. I will post it here in case others find this thread: jQuery(document).on('click','.thumbnails .zoom', function(){ var photo_fullsize = jQuery(this).find('img').attr('src').replace('-100x132',''); jQuery('.woocommerce-main-image img').attr('src', photo_fullsize); return false; }); ....


6

You can do that because you can add all the attributes you need: the_post_thumbnail( 'large', array( 'title' => get_the_title() ) ); Please read on in the Function Reference of the_post_thumbnail.


6

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. wp media regenerate --only-missing You could also use find . -name "*-*x*.*" | xargs rm -f to delete all of the thumbnails from your uploads folder. Make ...


6

Don't know why you want to do it when there're update_post_thumbnail_cache() in WordPress and set expire headers on server side. But you can try this in your functions.php: add_filter('wp_get_attachment_image_src', function($img, $id, $size, $icon) { $img[0] = $img[0] . '?v=20160505'; return $img; }, 10, 4);


6

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 srcset. You might find my answer here helpful. Briefly, in your case, adding this line: add_image_size ( 'double-size', 1270, 400, true ); ... will make a ...


5

As per the Codex entry for the_post_thumbnail(), you can pass an attributes array as a parameter: <?php the_post_thumbnail( $size, $attr ); ?> So you would just need to define the array; here's the Codex example, modified to include the title attribute: $post_thumbnail_attr = array( 'src' => $src, 'class' => "attachment-$size", '...


5

I found the same issue here and the solution from there works. The solution is as simple as pasting this: $content_width = 2000;// Value higher than your new 'large' width in functions.php Explanation copied from there(user Chip Bennett): I believe your issue is that the value set for the global $content_width variable (which is 640px in Boilerplate and ...


5

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].'">';


5

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', function( $atts = [], $content = '' ) { add_filter( 'wp_get_attachment_image_src', __NAMESPACE__ . '\\src' , 10, 3 ); $out = wp_playlist_shortcode( $...


4

JavaScript solution As the original answer already work with string replace, but has to get altered for each and every use case, here's a solution using a fast Regex .test() wrapped up in a self invoking function that uses the default method to prevent events (like following links) from happening. This plugin will delete the first occurrence of any 2-4 ...


4

When the first image is a Wordpress image attachment. in 3.6, there is an easier way. function get_first_image_medium_size_url($post_id) { if(!$images = get_attached_images($post_id)) return false; $first_image = current($images); if(!$src = wp_get_attachment_image_src($first_image->ID,'medium')) return false; $medium_url = current($src);...


4

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 upload images that are too small and then get this sort of result all the time. Secondly, WP will only make up a Srcset list of image sizes with the same aspect ...


3

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

Visit the Settings > Media page of your WordPress dashboard. Under the Image Sizes section, change all of the values to 0. Save the changes. This will stop WordPress generating thumbnails, medium, and large sizes of every image you upload. You will also notice that when you go to insert an image, the "Size" dropdown box is missing.


3

If I remember right you have to unset all the defaults and add the new Size there: <?php function mxdCustomImageSizes($sizes) { unset( $sizes['thumbnail']); unset( $sizes['medium']); unset( $sizes['large']); unset( $sizes['full'] ); $myimgsizes = array( 'full-size' => __( 'Full Size' ) ); if( !empty($sizes) ) ...


3

I use a plugin called Avatar Manager for that function. The author has also done a tutorial on how to write your own avatar manager plugin, but unfortunately it is also a bit outdated and doesn't work anymore. Although the plugin states it is compatible up to 3.6.1, it is still working in 3.8.1. I know at this stage the plugin is maintained as I just ...


3

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 head part of you html page. The og:image tag in particular: <meta property="og:image" content="http://graphics.myfavnews.com/images/logo-100x100.jpg" /> ...


3

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() ) { if (stripos($url, 'http://') === 0) { $url = 'https' . substr($url, 4); } } return $url; } function uploadDir($uploads) { ...


3

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 with the help of add-from-server plugin. Then with regenerate-thumbnails plugin you can then regenerate all of you images. Hope that helps!!


3

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 is to fetch a size larger than what you want, and then size it down via CSS and crop it. Let's say the registered sizes are 50 x 150, 300 x 300 and 1024 x 1024, ...


3

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 upload afterwards, because image are cropped at the time of uploading. You can either try to upload a new image, or you can trigger the re-cropping of previously ...


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