Jump to content

Image Variations - Ambiguous filenames


robinc
 Share

Recommended Posts

I have an issue where I want to have an image resized, but have both a cropped and non-cropped version available (of the same size!)

The code to do this is simple:

$imagefull = $image->size(320,320,array( 'cropping' => false);
$imagecropped = $image->size(320,320,array( 'cropping' => true);

However, this only creates ONE variant of the image:

eg. imagename.320x320.jpg

So the same image is shown twice in the output page, instead of the two options :(

Can anyone suggest a clean way of doing this? (ie. not duplicating every base image)

Is there a way of creating named Image Variations? And do these names go into the filename to guarantee uniqueness?

eg. $image->addVariation($name,$size,$options) or similar

Thanks

Link to comment
Share on other sites

Hi robinc,

welcome to the forums.

Yes, it is created only one version :(

Only workaround I know is to use the PageImage Manipulator. There you can pass a customdefined prefix to the filenames of image variations.

You need to install it and simply add a call to it like: $image->pimLoad('cropped')->pimSave()->size(320, 320, $options); for the second image.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...