Hi,

The class name for custom sized images in the 5.x-2.x version of img_assist has changed from just "image-img_assist_custom" to image-img_assist_custom-WWxHH where WW is the custom width and HH is the custom height. This makes it very difficult for lightbox2, other modules and themes to (a) theme the image assist images and (b) find them using javascript.

Would it be possible to re-instate the old class name convention or at least add another class name to the list, e.g. image-img_assist_custom image-img_assist_custom-WWxHH ?

Cheers,
Stella

Comments

sun’s picture

Title: class name for custom sized images has changed in 2.x version » Malformed class name for custom sized images
Category: feature » bug

We probably overlooked the fact that the filename is used as class name when this (trivial) feature was implemented. Of course, Image Assist should always use a default class name. I am even not able to imagine a use-case for a separate "custom" class, so we might drop that completely? Is there a use-case for those different image size preset classes at all?

stella’s picture

As long as there's a image assist specific class name, then lightbox2 is happy (or will be after a few adjustments). Lightbox2 also looks at the filename and removes the classname from it to get the original sized image, but i can figure that bit out.

Cheers,
Stella

sun’s picture

Hm - while we're at it, we could improve that, too. Do you have an idea how we could include information about the target size filename?

Unfortunately, I cannot find a related issue currently, which was a feature request to allow configuring the image size for images in the popup window. However, accounting for that idea, we'd have to pass on the file that should be used in the popup window, resp. Lightbox.

How about a (XHTML-Strict breaking) custom attribute? Abusing another attribute? Injecting the filepath as additional class name? Or just replacing/adjusting the href attribute of the link?

stella’s picture

What's the status of this? Lightbox2 doesn't need the filename to be modified, just as long as there's an image assist specific class name.

stella’s picture

bump

twod’s picture

I'd have to vote no to an XHTML-Strict-breaking attribute. Many developers try very hard to keep things Strict, and some browsers are very fond of breaking things if they aren't given what's promised by the DOCTYPE.
Maybe a class like "img-filename-My-Quirky-Fil3_name.JpG" would not be optimal, but I'd say it's the best shot.

hapydoyzer’s picture

This patch simply removes height and width information from class.

hapydoyzer’s picture

Status: Needs review » Active

This patch simply removes height and width information from class.

hapydoyzer’s picture

Status: Active » Needs review

Sorry :)

twod’s picture

Status: Active » Needs review

The patch-link in #7 leads to http://drupal.org/files/issues/. :(

hapydoyzer’s picture

Very strange... Reuploading.

Golem07’s picture

I have applied this patch to the latest (3.x) dev version of image assist. Since this small line of code is identical I hoped there is no big deal.

I actually does trigger lightbox now. Was so happy that it "worked" finally. Sadly just to find out that lightbox cannot find any image now and displays the dummy only as soon as I use a custom size :(
Is there a solution to this?

Many thanks in advance!

sun’s picture

Title: Malformed class name for custom sized images » Add consistent CSS class name for custom sized images
Version: 5.x-2.x-dev » 6.x-3.x-dev
Category: bug » task
StatusFileSize
new799 bytes

Uhm, that patch was horribly wrong - it limits you to create only 1 custom size.

Please test attached patch.

Golem07’s picture

Thanks a lot for the quick response.
I have applied the patch. But lightbox is still not being triggered. Checking the image with Firebug it seems to still have the dimensions in the class name.

hapydoyzer’s picture

Patch in #13 not working for me.

sun’s picture

Please make sure you flushed your *filter* cache. Image Assist provides a link at the top of its configuration settings page to do so.

hapydoyzer’s picture

@sun, your patch modify $attributes array, but it is not returned outside of the function...

tomsm’s picture

subscribing

NukeHavoc’s picture

This remains an issue in the latest Image Assist 5.x beta, with an added twist: where as Image Assist previously used pre-defined classes for "thumbnail", "preview", etc., it's now using custom sizes for everything. This wouldn't be a huge deal except for the fact that there is no consistent custom class name for the images that I can style (as previously noted, it's including the height/width information in the class name).

As a solution, couldn't there simply be an additional "img_assist_custom" class (above and beyond the standard "image-img_assist_custom-125x176" class) ? Would this confuse Lightbox? (I'm not using it, so I'm not sure what's needed for its integration to work properly).

As was mentioned elsewhere in the thread, is there a reason why the height/width information is being included in the class? Are people dynamically generating CSS to apply to these classes, or is there some other use I'm not seeing?

Robbert’s picture

You forgot to pass $attributes to image_display. Thus the last line of your patch should be return image_display($node, $label, $attributes);

fenstrat’s picture

StatusFileSize
new610 bytes

Here's an update to sun's patch from #13. Only change as per #17 and #20 is that $attributes is now added to the image_display() call.

agogo’s picture

Tired of update patches that doesnt work and confusion because of all different versions of the same module?

I just did this to my img_assist.module, line 1497 (6.x-2.0-alpha4):

Changed:
$size['key'] = 'img_assist_custom-' . $width . 'x' . $height;

Into:
$size['key'] = 'img_assist_custom';

...and then I flushed all caches. Voila!

Problem solved.

stella’s picture

Category: task » bug
Status: Needs review » Reviewed & tested by the community

This patch works great for me with latest 3.x dev branch. Any chance of getting this committed?

fenstrat’s picture

Confirmed, the patch in #21 still fixes this issue.

For those using lightbox2 there was a work around recently committed in #303780: Image Hander fails on custom image presets

sun’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for reporting, reviewing, and testing! Committed to 3.x.

A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.

Status: Fixed » Closed (fixed)

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