On-demand image variations

Author Message

Marc Boon

Tuesday 07 March 2006 5:18:51 am

I have a Image class containing 3 different variations of an image, each specified in a separate attribute of datatype image (original, medium, small). I don't want to use automatic scaling (variations are hand-cropped and scaled before uploading), so I removed the variations.
In image.ini.append.php:

[AliasSettings]
# store only original image
AliasList[]

In my class, only one image is required, so if the variation is not present, I need to create it on-the-fly as a scaled version of the required original. How do I do this?

Brian Gambill

Tuesday 07 March 2006 6:39:36 am

Asssuming the variations you need are sized consistently to one or two (or three or four) other sizes, put back the image aliases in image.ini and change the size(s) to what you desire.

Otherwise, I don't understand your problem. What I read is:
I don't want automatic scaling... then I want want scaling 'on the fly'

Does this mean you want scaling but only in the image when its sent to the user end, not stored on the server?

Marc Boon

Tuesday 07 March 2006 7:37:55 am

I want automatic scaling only as a fallback, when specific hand-created variations are not specified. In most cases they will be.

Marc Boon

Tuesday 07 March 2006 7:56:36 am

I could just specify two aliases (medium/small) to automatically create scaled copies of the original, and still have two extra image attributes in my class which can override the automatically scaled copies if they are specified. But in this case there would be also automatically created scaled versions of my custom medium/small images, giving a total of 9 images stored, where I only need 3. A waste of server space.

Related question: can you specify different image aliases for different classes or locations/sections?

Brian Gambill

Tuesday 07 March 2006 7:56:44 am

What method are you using to identify if the 'hand' variation is not present? Any image you upload will be called the 'original'. If you had a check box or something to indicate it’s wasn't the right size or un-edited, you could use that as a decision maker in your template code as whether to use the 'original' or one of the other variations (large, medium, small, custom).

Marc Boon

Tuesday 07 March 2006 8:09:43 am

Like I said in my original post, I have a custom Image class, which contains 3 image attributes. One (required) contains the large (original) image. The user can optionally upload two other images.
In the template, when a small image is needed, the code checks to see if this small image is specified by the user (attribute has content) if so, it will be displayed. If not, an automatically scaled version from the original will be displayed.

Brian Gambill

Tuesday 07 March 2006 8:13:11 am

I think I understand a little better. You want not just three different sizes of the same image, you want those different sizes to actually BE different images (not just scaled).

You can use different aliases depending on class/ section. This is all handled in the templates and how you call the images

THe following calls a medium size of particular attribute called picture which is the type image:

{attribute_view_gui attribute=$node.object.data_map.picture.content.data_map.image alignment=right image_class=medium}

So you custom class attribute name would replace 'picture'. You can use either/ both templates assigned to class/section and if statements to check for a variation.

old style:

{section show=$node.object.data_map.picture.content.is_empty|not}

Marc Boon

Tuesday 07 March 2006 8:25:09 am

"I think I understand a little better. You want not just three different sizes of the same image, you want those different sizes to actually BE different images (not just scaled)."

Right!
If some images need to be just scaled versions of the original, the user will not upload the variations manually, since then they can be scaled automatically. But in most cases, the variations are different images, like a detail of the original (cropped and possibly also scaled).

What you write about aliases I understand. But it implies that ALL images on the site are already scaled to all these variations. I wanted to know if you can specify how images are scaled *during upload*, depending on the containing class, or folder. So that you can have different types of variations depending on the class (or folder) that contains the images.

So, my question remains: can I create automatically scaled variations on the fly, without having ALL images automatically scaled during upload to all possible sizes ever needed (as specified in image.ini). I just want to avoid having 1000's of unused variations of images on my server.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.