We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

plugin: Image Sizer

Development and Programming

lumis's avatar
lumis
119 posts
17 years ago
lumis's avatar lumis

This plugin will resize any JPG GIF or PNG image to the desired size specified in your EE tag and cache the resized image to the cache folder. If you update the original image a new resized version will be created. If the image is not on the server the tag will not return anything.

{exp:imgsizer:size image="/images/news/moped.jpg" width="200" alt="My Title" id="img_5334" class="entry_img"}

will output

/images/news/cache/200x134-moped.jpg

you can Download here

       
jeremydouglas's avatar
jeremydouglas
292 posts
17 years ago
jeremydouglas's avatar jeremydouglas

cool, looks like a nice alternative to phptumb

       
PXLated's avatar
PXLated
1,800 posts
17 years ago
PXLated's avatar PXLated
/images/news/cache/200x134-moped.jpg

Cool…Be nice though if it included the width and height. If it doesn’t, the browser has to figure it out.

       
lumis's avatar
lumis
119 posts
17 years ago
lumis's avatar lumis

updated to V1.1 - Fixed a bug with recalling the image Cache - now outputs the width and height in the image tag

       
PXLated's avatar
PXLated
1,800 posts
17 years ago
PXLated's avatar PXLated

That was quick :-) Thanks, gonna give it a try tonight.

       
Cocoaholic's avatar
Cocoaholic
445 posts
17 years ago
Cocoaholic's avatar Cocoaholic

Very nice plugin, lumis.

I’d love to this plugin have Tag Pairs for even more flexibility, example:

{exp:imgsizer image="/images/news/moped.jpg" width="120" justurl="yes"}

{url}

{/exp:imgsizer}

or use the image as a background image:



Cheers!

       
lumis's avatar
lumis
119 posts
17 years ago
lumis's avatar lumis

Cocoaholic new version 1.3 now has what you want the original tag still works but i added this

{exp:imgsizer:pair image="/images/news/moped.jpg" width="200"}
    {url}
    {width}
    {height}
{/exp:imgsizer:pair}

Victor Im not really sure i know what you mean the width param is the scaling. the height is read from the original image and based on the scaling of the width the height is scaled proportionally to the width

maybe you are saying you would want to control the with and the height individualy? that would lead to squashed images etc. i just figured i would let the math figure that out.

       
Cocoaholic's avatar
Cocoaholic
445 posts
17 years ago
Cocoaholic's avatar Cocoaholic

Wow, thanks for the update!

       
PXLated's avatar
PXLated
1,800 posts
17 years ago
PXLated's avatar PXLated

I think what Victor is wanting is the ability to specify either the width or the height as the critical size and have the other scale in proportion. In general I find the width to be the critical factor but can see instances where it could be the height.

       
Joobs's avatar
Joobs
362 posts
17 years ago
Joobs's avatar Joobs

Are you planning on adding zoom-crop to this? It would be very handy for sites that have thumbnails all the same size.

       
ssouci's avatar
ssouci
70 posts
17 years ago
ssouci's avatar ssouci

Lumis:

could you please show an exact code sample of what I put into my template?

currently, I call up images in my posts simply by inserting the field name for my image… it’s called “image_big”, so I only have to insert the placeholder, ie: {image_big}

my images are all about 200px wide and are stored in the “images/uploads” directory right off my root

I want the images on my home page to appear as thumbs that are 50px wide

so… using the Resizer plugin, do I put in a line something like:

{exp:imgsizer:size image="/images/uploads{image_big}" width="50" alt="image"}

????? (the above code did not work at all)

also, I don’t have any “image ID”… what is that, and is it optional?

Note: I first downloaded the plugin, extracted zip, and placed the single .php file into my “plugins” directory using FTP

thx!

PS: as an experiment, I tried the plugin to try displaying one of my images files directly (ie, not using a variable placeholder like I want to do)…

I used the code:

{exp:imgsizer:size image="/images/uploads/cookinglight_200w.jpg" width="50" alt="My Title"}

my output page at least showed a small broken image of 50px wide, but I got the error: “Warning: imagejpeg() [function.imagejpeg]: Unable to open ‘images/uploads/cache/50x68-cookinglight_200w.jpg’ for writing in /home/cookbo2/public_html/system_ee123/plugins/pi.imgsizer.php on line 214”

       
rick.prince's avatar
rick.prince
111 posts
17 years ago
rick.prince's avatar rick.prince

ssouci, I did the exact same thing. Except with the direct approach I still didn’t get anything.

Lumis any thoughts? I’m running EE on my windows localhost with a stock install of apache.

       
PXLated's avatar
PXLated
1,800 posts
17 years ago
PXLated's avatar PXLated

I’m getting images with the direct link but can’t seem to get it working with extractURL or extractURL+ like one does with phpThumb. Would prefer to use this if we can get it working as it’s much lighter weight then phpThumb. phpThumb is somewhat overkill if all you need is image resizing/thumbnails.

       
lumis's avatar
lumis
119 posts
17 years ago
lumis's avatar lumis

ssouci the first try. because you did not get anything would make me think that /images/uploads{image_big} did not return the correct path to the image

the reason nothing would be returned would be that it could not find the original source image. Are you sure this would not be correct with the slash in front of {image_big}

{exp:imgsizer:size image="/images/uploads/{image_big}" width="50" alt="image"}

based on the error your second try returned i would assume you did not create a cache directory in your /images/uploads/ folder just make a cache folder /images/uploads/cache/ image ID is not required it just puts a id=”name” on the returned img code

rick.prince i don’t have access to a Windows setup to test this but i am willing to bet it is the way windows deals with paths. i will look into it.

PXLated can you explain how you are using extractURL+ to interact with image sizer

       
ssouci's avatar
ssouci
70 posts
17 years ago
ssouci's avatar ssouci

Lumis:

OK, I finally did get the second test to work (with image file specified directly)… this was done by creating a new directory called “cache” off my “images/uploads” directory as you explained

BUT, my primary test (to get images called up by a variable placeholder) is still not working

I used the line:

{exp:imgsizer:size image="/images/uploads/{image_big}" width="50" alt="image"}

this seems to be the correct path etc., but I get an error message:

Warning: getimagesize() [function.getimagesize]: Read error! in /home/cookbo2/public_html/system_ee123/plugins/pi.imgsizer.php on line 129 Warning: Division by zero in /home/cookbo2/public_html/system_ee123/plugins/pi.imgsizer.php on line 134 Warning: Division by zero in /home/cookbo2/public_html/system_ee123/plugins/pi.imgsizer.php on line 135 Fatal error: Call to undefined function: notfound() in /home/cookbo2/public_html/system_ee123/plugins/pi.imgsizer.php on line 191

NOTE: the variable “{image_big}” is a field name in my weblog database… a typical entry for this field in my edit screen looks like this:

https://ellislab.com/asset/images/team-photo/carluccio_a_completemushroombook_200w.jpg

any ideas?

thx!

       
1 2 3 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.