Hi,
I thought I would share this plugin I made. Use it to modify inline <img> tags in entries.
The plugin can be very useful for an example when you want to: - Modify existing img tags to use phpThumb. - Override width and height of inserted images. - Override or add parameters like align, class, alt, title - Enable lightbox on the image.
Documentation and download here:
Best, Sammi
bsjosten,
If you want to know if this plugin can be used in blog entries then the answer is yes.
The following code would make all images in {body} 100 by 100 square thumbnails of quality 50, and enable lightbox to view the original image.
{exp:weblog ....}
{exp:shj_imgmodifier phpthumb="true" phpthumb_path="/phpThumb.php" phpthumb_attributes="q=50&zc=1" width="100" height="100" lightbox="true"}
{body}
{/exp:shj_imgmodifier}
{/exp:weblog}
Best, Sammi
Thanks Sammi,
This will probably work for me most of the time.
However, sometimes I will have a weblog post that contains multiple images, where some should be bigger than others. Is there a way to control that from inside the post as opposed to in the template?
Thanks again,
/Bo
Sorry - it is not possible to act only on some of the images.
However, if you do not specify to override height and width, then the plugin will use the values from the img tag. So if one img was inserted with width=150 and another one with width=200 then the plugin should create thumbnails accordingly.
Actually the initial version of the plugin was only created to make images that where “scaled” inside TinyMCE or something look better by creating a new image that matched the size attributes in the img tag.
So you can have the users insert the original image into a WYSIWYG and scale to whatever size they want, then use this plugin to create a new image that matches the that size, and enable lightbox to allow the visitor to view the original image.
Best, Sammi
Sammi,
It seems that if I don’t specify a height argument, it is output with height=”0”.
This seems counterintuitive, shouldn’t it output without a height parameter at all?
In other words, I know what width I want, but I don’t know the aspect ratio of the source image, so I cannot specify a height without potentially distorting the image.
/Bo
Hi,
yes that is correct. It should not include height at all. Or maybe height=”“.
This looks like a bug and I will look into it as soon as I can. I am quite busy at the moment.
Thank you for pointing this out.
Info on Lightbox here.
Best, Sammi
Sammi,
I have solved my problem by writing a new plugin, based on yours, that does the image resizing, but also pulls urls from the gallery database to fill some additional needs I have to include gallery images in posts.
I decided to use a new parameter “size” instead of width and height, since what I really wanted was for the longer side of each resized picture to be the same. In other words, portrait pictures should have the same height as the landscape pictures are wide. This works nice in my layout.
So everything now works the way I need.
Thanks for a very good plugin start with!
/Bo
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.