Resizing on-the-fly

Still finding my feet with Zenphoto, but one feature I really like is the on-the-fly caching. It means that I can load my full-sized image into my gallery, but for displaying a resized version, e.g. in a forum post. I can call it into being simply by linking to it.

E.g. original image:
<website>/albums/<path>/filename.jpg

Resized version:
<website>/cache/<path>/filename_1024.jpg

This creates a resized version that is 1024 pixels wide - it strictly determines the width as far as I can tell, so if the image is taller than it is wide then the height will be greater than 1024. But in the Basic theme, there's an option to use the 'longest side' for resizing. So I'm wondering if there's a syntax or an option that will allow me to specify that the longest side is used in an on-the-fly resize.

Thanks

Comments

  • CJH Member
    Oh, and while I'm here, I'd like to post links of the form

    [url=<website>/albums/<path>/filename.jpg][img]<website>/cache/<path>/filename_1024.jpg[/img][/url]

    so that readers of the forum will see a resized image in the forum post, but when they click on it they are taken to the full sized image. It's not too much of an effort to construct this link manually, but if I could display it alongside the thumbnail in my Basic gallery page that would make life a lot easier. What's the best way to approach this?
  • acrylian Administrator, Developer
    There are more parameters possible. Usually you don't create cache files like this but via the image processor `zp-core/i.php`(well, of course this does this). Its comment block provides all parameters possible. All image functions for resizing (see the documentation) use this. If you use cropping you will notice that the cached file name contains more values.

    If you like to add something to the theme you will have to edit it. I suggest to also review the functions documentation (see the user guide) for image functions. Of course I suggest to read the theming tutorial first to get familar with some theme basics.
  • CJH Member
    Thanks. Ok, now I see the different resizing options, and I see that a cropped image has other parts in the name (e.g. filename_100_cw100_ch100_thumb.jpg. But the cw and ch 'options' don't work as a way to create the image on-the-fly - it doesn't 'call the file into existence' the way the _1024 suffix does.

    I appreciate that it's not the intended use of the cache, but nevertheless it is a really useful feature. If I want to display a downsized image in a forum post I don't need to create it in advance, I simply paste the link to the full image, change '/albums/' for '/cache/' and then type the width suffix just before the .jpg extension. Clearly there are enough 'smarts' in the image processor to extract the width parameter from the filename, but not the cw and ch parameters. Is that right? And even if not, there is no parameter for 'longest side'. I guess I'll stick to resizing via the width.

    Thanks for the pointers on editing the theme. I'm a PHP novice, but will take a look.
  • acrylian Administrator, Developer
    The "longest side" is just an internal setting used at least for the "default" theme image functions. There is no parameter for it.

    Btw, there is an older bbcode plugin: http://www.zenphoto.org/news/generate-bbcode/
    No idea if that still works but maybe you can adapt it to your needs. Theme editing will be necessary in either case.
Sign In or Register to comment.