For some reason Wordpress is cropping some of my thumbnails proportionately rather than to specific dimensions for some images, and cropping them to specific dimensions for others.  I want it to crop all my thumbnails to 728 x 410 pixels, but some of them are taller than 410 pixels.  Here is what I have in my functions.php:  add_image_size('main-thumbnail', 728, 410, true);   Here is what I have in my content.php:  &lt;div class="thumbnail"&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt; &lt;?php the_post_thumbnail('main-thumbnail'); ?&gt;&lt;/a&gt;&lt;/div&gt;   This works for some images but not for others, and I don't know what is causing this.  I have also regenerated my thumbnails using the Regenerate Thumbnails plugin but nothing changed.  What is the reason for this?
123377
For some reason WordPress is ignoring my thumbnail sizes and keeping thumbnails cropped proportionately instead of specific dimensions. Here is what I have in functions.php:  add_image_size( 'main-thumbnail', 728, 410, true );   and in content.php:  &lt;div class="thumbnail"&gt;     &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;        &lt;?php the_post_thumbnail( 'main-thumbnail' ); ?&gt;     &lt;/a&gt; &lt;/div&gt;   I added these two things and regenerated my images with the  plugin, but it doesn't seem to matter. The images don't change.  For some reason WordPress isn't recognizing the hard crop and is keeping the images proportional, so some of my images are way taller than 410 pixels. Why is this?
84856
I want WordPress to return the first post image or a default image if no featured image has been set. My theme uses the_post_thumbnail many times, so I don't want to go through and change all references to a new function. I'd rather filter the core. Here's what I've added to functions.php:  add_filter('post_thumbnail_html', 'my_thumbnail_html', 10, 5);  function my_thumbnail_html( $html, $post_id, $post_thumbnail_id, $size, $attr ) {     global $post, $posts;     if (has_post_thumbnail() ) {         echo get_the_post_thumbnail( null, $size, $attr );     }     else {         $first_img = '';         ob_start();         ob_end_clean();         $output = preg_match_all('/&lt;img.+src=[\'"]([^\'"]+)[\'"].*&gt;/i', $post-&gt;post_content, $matches);         $first_img = $matches [1] [0];         if(empty($first_img)){             $first_img = get_bloginfo("template_url") . '/images/default.gif';         }         return $first_img;     } }   How do I hook this correctly?
37077
Hi my client has given me a load of images for the site I'm building for him, they are going in a Javascript Image Nivo Slider Banner at the top, the size of the banner is 720px x 200px but the images aren't.  I can crop the images, but I wonder if there is a way to resize them and change the proportion without destroying the quality, or due to the nature of how pixels work is this not possible?  I would like to be able to turn them into wide angle images and work from there.  I have Photoshop CS6 Ext.
111836
I really love the way  works, but unfortunately it doesn't look very sharp on a , especially when juxtaposed with browser-rendered text. If you made the generated image twice its current size, it would circumvent this problem.  Could you please generate larger source images? Keeping the same width and height HTML attributes will mean that the image won't look any different for current users, so there's no chance of anything breaking.  It's a small difference, but quality is in the details!
43712
I am using wp_get_attachment_image_src to construct the srcset attribute of an img tag. In that attribute I want to output a comma separated list of image urls along with the image widths.  Using the Media Settings page, I have configured the image sizes to be as follows:   Thumbnail size: 150x150 Medium size: 640x480 Large size: 1024x768 Small size: 278x320   The wp_get_attachment_image_src function returns the correct urls and the correct widths for the image sizes full, medium and small. small is a custom size I added using add_image_size.  If I call wp_get_attachment_image_src( $image_id, 'large' ), the returned array looks like this:  array (     0 =&gt; 'http://localhost/wp-content/uploads/2014/10/image-1024x768.jpg',     1 =&gt; 640,     2 =&gt; 480,     3 =&gt; true, )   Checking the image which can be found at that url turns up the image with the correct dimensions.  Currently i am using the php builtin function  to circumvent this problem, but this function call takes significantly longer than simply accessing the index returned by wp_get_attachment_image_src:  Without getimagesize (mtime before and after execution):   '0.83761000 1415195440' '0.83831600 1415195440'   With getimagesize:   '0.34808000 1415195635'  '0.35323900 1415195635'   What can I do to make wp_get_attachment_image_src return the correct dimensions?
45625
Noticed in my  that the avatars of the Top Network Askers are blurry.  Quick check showed it's because SE is requesting the 16x16 thumbnail, while having 30x30 size of the image itself, which cause the image to stretch.  Changing the requested image to 32x32 makes the avatars more clear, e.g.  vs   Live demo. Nick looks like this at the moment:        Changing to  32x32 will make it much better:
5794
I need to create thumbnails from multiple .png files and would like to do this using ImageMagicks convert utility. To recursively find all files that are not thumbnails themselves, I am using the following call (split into two lines to make it readable):  find . -type f -name "*.png" -not -name "*thumb.png*" \   -exec convert {} -thumbnail 200x200 {}.thumb.png \;`   But this would of course create a file named a.png.thumb.png when running it on a file called a.png. How could I remove the .png extension from the second {} parameter passed to convert?
76750
Full:    Cropped   :    In the second image (cropped) which is the same as the first (full) image... why the 1st Gate outputs "0"?
4199
A   B   C   D   E   F             I don't even know. It just seemed weird.  Yes, I understand I could just avoid doing something like that. But the problem already exists with a single level.   Consider having 2 images in a post. Both exceed the maximum width of a post. One is nested in a list. Key to this issue is that my original images were much larger. They were automatically resized.  Image    List      I think it looks weird.
108477
I am trying to figure out how to paginate a post for it's images. I have a custom post type set up to act like a gallery - images only. And would like to paginate the images. I am having a hard time trying to figure out where to start with this.   I am using get_posts() within the loop to get the images attached to the post. I would like to set it up so 30 images display per page.   Any idea where I should start? Or do I need to alter the way I have this gallery feature set up in WP?  Thanks in advance!
123008
I was sent an image (.psd) that has transparent background. When I export it the resulting .png preserves the transparent background so the image actually takes more space on a website than necessary. It's a logo image.  I'm trying to adjust the transparent canvas site to only take the space by the image itself.  Alternatively, how do I export it so that the resulting .png is only the size of actual logo (rectangle) not including the transparent space (bigger rectangle).  Thank you.
121373
Good Morning Friends,  I am creating a Visualforce for my users to upload photos and these photos are saved in the attachments object, but I wonder if there is any way before the picture is saved I can give a resize the image to 800x600 when the image is larger than this size, if less is saved normally.  Could anyone help me in this task? Thanks to all
25371
Is it possible to resize an image in an answer? For example,  has  that should have the image in the answer, but it's too big.  Is there a way to handle resizing?
105656
I want to change the wording in the Default thumbnail metabox to 'Set default thumbnail' instead of 'Set featured image'. How can I do this?
98338
Before I jump on to the problem, let me first congratulate  and his team for the newly re-designed Stack Exchange blog. I like it very much, great job! While searching on Google, I stumbled upon  blog post of Jeff Atwood and found few broken images. There are currently four images are broken on this post, Here is one of them:    Upon doing an inspect element on one of the broken image (same goes for all other broken images on the post), I found out that it is currently pointing to: https://blog.stackoverflow.com/wp-content/uploads/stackexchange-genuine-example11.png The newly re-designed Stack Exchange blog is now moved to a new location:  and the old blog URL i.e.  has the correct mapping of URL redirection (also called URL forwarding) and works perfectly. But, the problem lies in the latter part i.e. /wp-content/uploads/ directory structure does not exist anymore at the new blog location. I read the Jon Chan's  post (nice writeup! btw) where he talks about his custom Python script. Here is the relevant excerpt taken from that post:  I wrote a Python script to go through all the imported posts, looked for references to WordPress hosted content, download all the static assets into images/wordpress in the repo, and changed all the links to relative paths on Jekyll. Worked surprisingly well.  In other words, all of the old /wp-content/uploads/ static assets is now resides under the /images/wordpress/ directory at the new blog location. So, Jon's find and replace script should have worked (which it did for the most of the part) as intended to be but apparently it did not catch few of them. At least on  blog post and few other like ,  or . We could possibly have more but these are the ones I have found so far. I believe it's a minor bug somewhere in the script and could be fixed with few lines of code tweaking. Also, the static content link mapping problem would not have occurred at all if the directory name was unchanged as the URL redirection (as stated above) would have taken care of it. But, there must a reason for this change. Upon investigating further, I found out that the issue with broken images does not end here. They will still appear as broken even if Jon's script replaces the path to the correct one. Because the images have not been uploaded (or copied) to the blog's new /images/wordpress/ directory at all. They are missing! For example, try clicking on the following link: ## I replaced old dir. path /wp-content/uploads/ to the new /images/wordpress/  So, in a nutshell, in order to fix this broken images link problem, we need to make sure that not only they are pointing to new path i.e. /images/wordpress/ but also do exists (i.e. uploaded) at the blog's new location. Please fix this at your earliest.
2646
The current image handling is minimal, there is no rescaling a all and the full image is simply scaled to the width of the post.   This works well until you have images that are wider than the 640px available for posts. There are two important categories of images that pretty much always break this limit: Pictures taken with a digital camera and screenshots. Sites that would benefit from an improvement here would be especially Photo.SE, Arqade, DIY and other image-heavy sites.  The current result of this for inexperienced users is that they put the full-sized image in the post. This means a waste of bandwith for everyone looking at it, and also makes the full-sized image not accessible to non-technical users.  An experienced user will rescale the image before uploading. This takes more time and also makes the full-sized version of the image unavailable for everyone.  A very experienced SE user can work around the whole thing and use the automatically created thumbnails from imgur to create a preview image linked to the full-sized one. This is only known to very few users, it is not discoverable and quite a lot of work.  I'll use a project from a developer that is rather well-known around here as an example how the image handling could be done better: .  When uploading an image   it should be rescaled automatically to the width of the post the image should be linked automatically to a lightbox (or to a new tab) that will show the image in the maximum possible size on the screen.   There should be no need for a user to do any manual work, this should just work automatically.
22542
What's the most efficient way to resize large images in PHP?  I'm currently using the  function imagecopyresampled to take high resolution images, and cleanly resize them down to a size for web viewing (roughly 700 pixels wide by 700 pixels tall).  This works great on small (under 2 MB) photos and the entire resize operation takes less than a second on the server. However, the site will eventually service photographers who may be uploading images up to 10 MB in size (or images up to 5000x4000 pixels in size).  Doing this kind of resize operation with large images tends to increase the memory usage by a very large margin (larger images can spike the memory usage for the script past 80 MB). Is there any way to make this resize operation more efficient? Should I be using an alternate image library such as ?  Right now, the resize code looks something like this  function makeThumbnail($sourcefile, $endfile, $thumbwidth, $thumbheight, $quality) {     // Takes the sourcefile (path/to/image.jpg) and makes a thumbnail from it     // and places it at endfile (path/to/thumb.jpg).      // Load image and get image size.     $img = imagecreatefromjpeg($sourcefile);     $width = imagesx( $img );     $height = imagesy( $img );      if ($width &gt; $height) {         $newwidth = $thumbwidth;         $divisor = $width / $thumbwidth;         $newheight = floor( $height / $divisor);     } else {         $newheight = $thumbheight;         $divisor = $height / $thumbheight;         $newwidth = floor( $width / $divisor );     }      // Create a new temporary image.     $tmpimg = imagecreatetruecolor( $newwidth, $newheight );      // Copy and resize old image into new image.     imagecopyresampled( $tmpimg, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height );      // Save thumbnail into a file.     imagejpeg( $tmpimg, $endfile, $quality);      // release the memory     imagedestroy($tmpimg);     imagedestroy($img);