I use the same image in both our main web-theme, and in our mobile-theme. The latter needs a smaller height-width of the image.

That's why we use two different presets. One crops to 540 pixels width, and one that crops to 200 pixels width.

With imagecrop today I need to make the crop twice, for both of my presets.

Would it be possible to crop two different presets simultaneously?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gooddesignusa’s picture

I had a similar problem. On the full view of a node the image would be cropped. In teaser view I wanted to make a thumbnail of the cropped image. I didn't want to have to make them crop the image twice. I basically cheated and did a search and replace and manually ran the cropped image through another preset. I'm sure there is a better way to do it but i'm not a drupal pro and this got the job done. The first line was needed to strip out the image height and width. If I didn't strip them out the image would be smaller but stretched. Second line just replaces part of the location of the image with another location.

$output2 = preg_replace('/\<(.*?)((?:width|height)="(.*?)")(.*?)((?:width|height)="(.*?)")(.*?)\>/i', '<$1$4$7>', $output);
$output2 = str_replace("/story_full/", "/story_view/files/imagecache/story_full/", $output2); 
echo $output2;

I used this on a views template file. example: views-view-field--field-story-img-fid.tpl.php

Hopefully my post helps you look @ the problem from another angle.

I would love a check box that said use same crop region for this preset or something like that. But in the mean time this works.

espenmoe’s picture

thx!

tacituseu’s picture

Title: Same crop on multiple presets » Re-use crop selection in another preset
FileSize
2.49 KB

Adds action 'Javascript crop reuse selection', Tested with imagecache 6.x-2.0-beta10 and current dev of imagecrop.

tacituseu’s picture

Status: Active » Needs review
gynekolog’s picture

tacituseu: working but only for one another preset

tacituseu’s picture

Not sure what you mean by that, is there no way to select other presets in 'Javascript crop reuse selection' action's configuration ? All presets containing 'Javascript crop' action should show up there.

gynekolog’s picture

Excuse me, my english is terrible. I have 'Javascript crop reuse selection' on another one preset, all is ok. But when i use it on another next preset, function stop working and all preset with 'Javascript crop reuse selection' are like without this function

Wolfgang Reszel’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

We need it for D7, too.

olrandir’s picture

I'd love to be able to do this in D7 as well. Subscribing.

olrandir’s picture

FileSize
2.32 KB

Working on transferring the image style re-use functionality to D7, so far I've only copied what the D6 patch does into the D7 module file. I'm stuck on the "imagecache_preset_by_name" function, which does not seem to be available for D7. What should I use in its stead? I'm a relative newbie (only worked with drupal for 2 months), so any help is appreciated!

Attaching patch which DOES NOT WORK, only produces "Call to undefined function" error when calling the aforementioned function.

edit: also, setting git up to create a patch that way proved too time-consuming for me to do right now, so for the time being the attached patch is created with "diff -up".

tacituseu’s picture

Have a look at canvasactions_aspect_image() from imagecache_actions-7.x-1.x-dev.tar.gz for some clues.

dddbbb’s picture

Subscribing. +1 for a D7 version.

JonasMikkelsen’s picture

Subscribing. Also need the D7 version.

nils.destoop’s picture

Currently looking to add the patch from #10 to current dev. Thx olrandir :)
I will also add the patch for d6 version.

nils.destoop’s picture

Re-use crop selection is now working in 7.x.dev

olrandir’s picture

Tested on D7.2 and works nicely, thanks!

One comment: the re-used image style doesn't change when the original image style changes. That is, if we have a crop style called big_gallery and a style called small_gallery that re-uses the previous style (and, say, scales it to something smaller), re-cropping the big_gallery style won't change the small_gallery once it's been rendered.

This also means that if you set your content type to display the small_gallery style (which means it will be rendered immediately upon upload), it will use the default crop, and not the user-selected crop settings that will be applied *after* the upload. Clicking "update style" in the image style configuration page will create the correct image style.

Alx’s picture

I try several times on D7.4 but its not working for me.
In image styles I create new style "recrop" and add effect "Reuse a javascript crop selection" but when I need in content to choose "Available imagecrop styles" there are no "recrop" effect to choose.

Do I need first add "Javascript crop" effect and then "Reuse a javascript crop selection" in "recrop" or "Reuse a javascript crop selection" work as alone effect.
Or maybe I do something wrong..

I need this multiple crop (re-use crop) for one newspaper publisher project where from one scan page I need to make multiple article crops.

I need help ASAP only this solution wait me to finish web portal.

Thanks in advance to everyone who can help me.

olrandir’s picture

First create an image style for the original crop, then create an image style and select re-use image crop. In the settings for that effect, select the original crop style you created. Then add any other effect you want.

Alx’s picture

FileSize
40.16 KB
11.04 KB

At first thank you olrandir for suggestion how to use "Reuse a javascript crop selection".

Today I have another problem when I am using "Javascript crop" with >>Add a new file with Reference existing<< its not posible to use second time same image to crop. If you crop second time it will be change also on first time using image crop.

When I need this to use...

First with some content I upload newspaper pages.. (lets say 20 pages)

Then I add content page where I need to crop articles. With >>Add a new file with Reference existing<< I find page from newspaper (lets say page No. 6) and use some "Javascript crop" style.

Then I add another content page where with >>Add a new file with Reference existing<< I open same newspaper page (page No. 6) and I want to use another crop. When I make second crop in another content with same newspaper page I loose parameters from another crop of that pages (mean now first content page have same parameters of crop from second content page).

At the end.
At this moment with this module its not possible to make more than one crops when you are using AUTOCOMPLETE REFERENCE OPTIONS to select same image more than once.

I need some another advice how I can make this I with this or some other module.
If you need more informtions which can help you I will be glad to support to make this module better.

Thans in advance for any other suggestion or solution for croping more than once from one image.

Alx’s picture

Title: Re-use crop selection in another preset » Re-crop (multicrop) from same image select with AUTOCOMPLETE REFERENCE OPTIONS
FileSize
40.16 KB
11.04 KB

POSTED IN NEW ISSUE!

Re-crop (multicrop) from same image select with AUTOCOMPLETE REFERENCE OPTIONS
(Maybe I need this to put in another issue)

Thanks

Alx’s picture

Category: feature » bug
Issue tags: +re-crop, +multiple crop
nils.destoop’s picture

Title: Re-crop (multicrop) from same image select with AUTOCOMPLETE REFERENCE OPTIONS » Re-use crop selection in another preset
Version: 7.x-1.x-dev » 6.x-1.x-dev
Category: bug » feature
nils.destoop’s picture

Status: Needs review » Fixed

This is now also in D6 dev version

Status: Fixed » Closed (fixed)
Issue tags: -re-crop, -multiple crop

Automatically closed -- issue fixed for 2 weeks with no activity.