Needs work
Project:
Image
Version:
6.x-1.x-dev
Component:
image.module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
5 Apr 2009 at 20:13 UTC
Updated:
5 Sep 2009 at 15:37 UTC
Jump to comment: Most recent file
Comments
Comment #1
ghoti commentedThe attached patch fixes this by allowing height and width to be passed as $attributes to
image_display(). If an empty attribute is passed, it gets unset() so that it will be eliminated from the eventual HTML output.Comment #2
ghoti commentedFor reference, with this patch, image_display could be called with something like this:
Of course, other attributes can still be supplied as they could before.
Comment #3
joachim commentedMy take on this is still that it's best done with CSS in your theme.
I'd like something less noisy in the patch though. Could we do all the caller overriding in one go?
Maybe load up $image_info_attributes with the stuff we get from $image_info, and then do:
$attributes = $attributes + $image_info_attributes
I'm not up on how PHP handles clobbering array keys -- we'd want the passed-in $attributes to win, basically.
Also, we want the class attribute to marge not clobber -- maybe append our own classes after the array merging.
Comment #4
ghoti commentedWhile I agree that in doing this in CSS is generally preferable, there will still be cases where someone will want to control image display while using a default theme. And hey, the cost of a couple of extra if's per image seems cheap...
Regarding passed-in attributes, are you suggesting that if someone passes
that gets sent to HTML? If so, then I disagree; you've got the protection against that already in the function, and the reasoning that put it there is sound. Other than that, as the patch stands, passed-in attributes *do* override anything learned from image_get_info().
array('height'=>''), then we should actually include an empty height attribute in theIt seems to me that the only way to avoid clobbering keys is to check for their existence before adding them, which we're doing with this patch. The only attributes that image_display() adds itself are width and height. The image_get_info() function returns other data that are *not* appropriate as attributes in an
, so just merging the two arrays together wouldn't work.
Regarding the noise, I tried to figure out how to shrink the if-nest but I couldn't. This is the tightest I could make it while capturing the logic required. Any other suggestions would be welcome.
Comment #5
joachim commentedThis is what I had in mind:
Our class would then need to be appended.
Comment #6
sunComment #7
pebosi commentedi created a patch, which uses array_merge to combine image_info with attributes and remove empty values with array_filter. please review
regards
Comment #8
pebosi commentedComment #9
joachim commentedI've had a closer look at what's going on here.
We can't simply replace these lines with array merging:
These bits can only pass data into the new array if it's not empty, as it says in the comments.