Plugin

Archived
Forum
(read-only)

CE Image

ExpressionEngine 1.x, ExpressionEngine 2, ExpressionEngine 3

Back to this add-on's main page
View Other Add-ons From Causing Effect

     

Make bulk tag ignore images smaller than max_width?

Support (Resolved)

JamesB
JamesB

Is there a way to make the bulk tag ignore images that it doesn’t process… images that are smaller than the max_width? I am using this on a Wygwam field so that authors can just upload any sized image and it will get automatically scaled and have a modal link to the full sized image. Seems to work fairly well except it is applying the modal link to all images whether they were scaled or not. This is definitely not a desired behavior for me since it is causing annoying pop-ups that don’t actually result in a larger image for images that are smaller than the max_width. So is there a way I can make the tag apply only to those images larger than the max_width? Below is the code I am currently using.

{exp:ce_img:bulk max_width="621" remote_dir="/images/made/" output='<a href="{orig}" class="modal"><img src="{made}" /></a>'}
{blog
-body}
{
/exp:ce_img:bulk} 

 

Causing Effect - Aaron Waldon
# 1
Developer
Causing Effect - Aaron Waldon

Hi JamesB!

Which version of CE Image are you using?

JamesB
# 2
JamesB

I’m using 2.4.4.

JamesB
# 3
JamesB

Hi Aaron… any help on this one?

Causing Effect - Aaron Waldon
# 4
Developer
Causing Effect - Aaron Waldon

Hi JamesB!

You cannot have CE Image ignore images off of a parameter (like the max_width= parameter), but you may be able to to use conditionals. Have you tested that out? I just tried the following out and it seemed to work as expected for me:

{exp:ce_img:bulk max_width="621"
 
remote_dir="/images/made/"
 
output='{if width < 100}<a href="{orig}" class="modal">{/if}<img src="{made}" />{if width < 100}</a>{/if}'}
 {blog
-body}
{
/exp:ce_img:bulk} 
JamesB
# 5
JamesB

I’m confused, is this testing the width pre or post scaling? I’m assuming it is post scaling… so in that case wouldn’t it always evaluate true? I’m a little unclear why the conditional is against a width under 100px when the max_width is 621px. Could you clarify?

Causing Effect - Aaron Waldon
# 6
Developer
Causing Effect - Aaron Waldon

is this testing the width pre or post scaling?

Post. If you want to test against the original width, use {width_orig} (please refer to the Variables page).

I’m a little unclear why the conditional is against a width under 100px

It’s an example. You can change it to whatever number you want to test against. ;)

JamesB
# 7
JamesB

oh I see… So for my usage, I’d probably just have it be 620 so that any image that was smaller than the max_width does not have the link applied. Makes sense.

Causing Effect - Aaron Waldon
# 8
Developer
Causing Effect - Aaron Waldon

Yeah. Advanced conditionals are parsed after exp tags, so that’s why it works. :)