Why does the add_image_size() function not create a copy of the thumbnail image in wordpress? - image

I have uploaded a photo in WordPress. I am trying to post a thumbnail of the image using a predetermined width while constraining the height proportionally.
In functions.js:
add_image_size('width-130', 130, 0, false);
On the page that outputs the thumbnail:
the_post_thumbnail('width-130');
According to the WordPress docs(http://codex.wordpress.org/Function_Reference/add_image_size), it says:
WordPress will create a copy of the post thumbnail with the specified
dimensions when you upload a new thumbnail.
Currently it is outputting the full thumbnail image with a width attribute of 130. This still requires the full size image to load, which is not what I want. I would like for WordPress to create an actual copy of the post thumbnail with the correct dimensions, and not just to set the width attribute. How can I achieve this?

I discovered my mistake.
Since I had not re-uploaded the image file, it was still trying to access the full size image which was the assigned image for that post, while adding the width attribute. Once I re-uploaded the image, the add_image_size() function is now actually creating a copy of the thumbnail with the correct dimensions.
I apologize for asking this question. If the community wants, I can close it but I figure it might be good reference for WordPress newbies such as myself.

Use this plugin to regenerate thumbnails.
http://wordpress.org/plugins/regenerate-thumbnails/

In case anyone runs across a similar problem, this may help. add_image_size generates derivatives that are smaller, but not bigger or the same size. Thus if you are trying to make a monochrome derivative image, uploading an image the same size as the monochrome, it will not be available and techniques like this one won't work.

Related

Drupal resize image on the fly

Is it possible to resize images on the fly and cache the result with Drupal?
I have some big images (e.g. 2000x2000px) and I want to display a preview of the e.g. 100x100px.
I know there is a theme_image_style function. But it seams to only create the <img> with the right size and not effectively resize the image.
I look at modules/images/image.admin.inc and they used the function [image_style_create_derivative][2].
Yes, you should use Drupal's Image styles (Configuration -> Media -> Image styles). There you should create your style.
Then, on front-end, when ever you want to display image with that style (in that resolution) you can use image_style_url() function:
https://api.drupal.org/api/drupal/modules!image!image.module/function/image_style_url/7
It accepts 2 parameters - one is image style machine name and other is image URI, which you can get if you print out all image field properties.
You can also select image styles from back-end interface...i.e. when creating a view for some image you can select to be displayed in specific image style.
In both cases those image styles are generated the first time image is used.
In response to your comment on MilanG's answer, using image_style_url() is the best option on the backend. There is also
https://www.drupal.org/project/resp_img
which may be something worth looking into. From a UX perspective, you don't want to force the user to load a 2000x2000 px image every time they load the page. Regardless of the outputted size, the image is still going to render as a 2000x2000 px image with a large size. image_style_url() or using image styles in the GUI create a new file that will load much quicker and is the preferred method.

Magento Images are rotating when uploaded

This only happens on the product pages with images with a larger height than 500px approximately. Caching is disabled. Products display correctly at smaller sizes but i need a solution that doesn't require image resizing before uploading.
I believe its something to do with using multiple image resizer program and some of the meta information in the image.
Thanks
It sounds like there is EXIF data in the jpeg which records which way 'up' is. Either this info is getting ignored when you upload but is not ignored on your PC - explaining why the image looks the right way up when you view it on your desktop, but the wrong way up in Magento, or vice versa.
Can you use an art program or bulk convertor like XnView to either apply or remove the EXIF data before uploading? Then you might need to manually rotate some images.

Possible to get varying sizes of Tumblr theme options uploaded images?

In using Tumblr theme tags, you can use {PortraitURL-16} or {PortraitURL-128} to get a 16x16px or 128x128px (respectively) portrait image URL. Similarly you can use {PhotoURL-500} to get a 500px wide URL to that image in a photo post.
I'm wondering if it is at all possible to do the same thing (specify a dimension value) for custom uploaded images in my Tumblr theme. For example, I use {image:Avatar}, and if someone were to upload a 1280 pixel-wide photo, I'm still going to be display it at 60x60px. Is there any way to specify {image:Avatar-60} so I'm not loading a huge image on every page load?
Afaik, no. Images are processed in three different ways on Tumblr.
Photo / Photoset / Panoramic Post
When creating a new Photo / Photoset post any images added, Tumblr will process, and create multiple copies at various sizes. You can then retrieve a specific size by using the appropriate theme operators:
{PhotoURL-HighRes}
{PhotoURL-500}
{PhotoURL-400}
{PhotoURL-250}
{PhotoURL-100}
{PhotoURL-75sq}
Theme Assets
You can also upload an image whilst customising a theme, via the customisation page. Unlike Photo / Photoset Post, these images are processed and retain their original size and multiple sized versions aren't created.
Post Body / Caption
Finally you can upload an image whilst adding content to the post body / caption. These images are processed and capped at 500px high / wide.
Hope that helps!

Wordpress upload image size

Kinda new to wordpress.. Creating my own theme. When I upload an image and put it in a post it comes out at 300x183 pixels but the original file I upload is 1800x1100 pixels. Wordpress alters my size when i upload it.This is what i get in the url on the post NDAppleProductMockUp-300x183.jpg.. It restricts the size of the image. When i go into the image properties within the post and click original nothing happens it stays at 300x183.. I have tried to work it out but can't Any suggestions guys..
Thanks
Unfortunately, WordPress does not resize the actual image that you upload. It creates 3 smaller versions of it, leaving the uploaded image untouched. I would suggest that you create all of your images at 1800x1100 before you upload them.
Another solution would be to link to the "big-sized" image when you "Insert into Post"... unfortunately, you would have to know the filename of the large image. I check the source code and this part of the media system does not appear to be pluggable.
Another option may be to check out this plugin:
http://wordpress.org/extend/plugins/nextgen-gallery/
This link here details how You can change what image size will be displayed
http://codex.wordpress.org/Function_Reference/add_image_size
also when u attach to post you can set the image size in the setting
THE SETTING is Before you attach the image!
you are trying to change an image that has already been attached (the attached image was in a mid or small size to begin with) so it is already at its original size.

Mediawiki Image Resizing - Trying to understand how it works

I have Mediawiki 1.21.2 installed. I have also set up ImageMagick on my server and have enabled it in LocalSettings.php. I have already read the Mediawiki's Images manual and I just need to clarify this:
If I am adding a plain image without adding the "thumb" option, will the image be automatically resized for the width I have mentioned or will it only skrink the dimension to that size but still has the original file size? For example, if I using this:
[[File:Sample_Image.jpg|250px]]
In the above statement, I can see that the image will be displayed with the maximum width of 250px. Lets say, if the original image is like 800px X 600px with a file size of 2MB, will the re-sized image for the above dimension will be reduced to only a few KB when the image is reduced to a width of 250px (or) will the image size shown in the article page will still have the original filesize of 2MB but only shrinked to 250px width but doesnt reduce the original filesize? I am just wondering since a lot of my users upload big pictures and these pictures have big file sizes. At the moment, I have added the image like this in my templates:
<div class="main_article_image">[[File:Sample_Image.jpg]]</div>
and then using css, I have minimized the image size like this:
.main_article_image {
max-width: 250px;
height: auto;
}
The current method resizes the images in the articles pages but the file size for these images are still huge and the article page takes too long to load. So I manually resize all images and upload a smaller size for images each time that takes more manual work. Therefore, I am trying to find out if adding the 250px with the image tag like: [[File:Sample_Image.jpg|250px]] will automate this work for me!
I have these settings on my LocalSettings.php for imagemagic:
$wgEnableUploads = true;
$wgGenerateThumbnailOnParse = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/local/cpanel/3rdparty/bin/convert";
Can someone please confirm if this will work? Am I doing it the wrong way by resizing it via css? I know adding "thumb" parameter resizes the image, but will it work the same if for plain images without the thumb parameter? If it will, then I need to edit all of my templates and I just want to confirm before I go ahead changing the templates. Anyone who can clarify this will be helpful for me.
Yes, it seems that a smaller image file is generated even without the "thumb" parameter.
For example if you check the help page on images with the example "[[File:Example.jpg|50px]]" and check the url of the small image that is displayed, you'll see that it uses the thumb version /thumb/a/a9/Example.jpg/50px-Example.jpg instead of the full-size version /a/a9/Example.jpg

Resources