In almost every module there are themed images, sometimes also themed linked images. At least in every meaningful theme design you are facing the trouble: Everytime you want to theme a linked image, you have to inject a bunch of cryptic arguments:
l(theme('image', 'anypath/images/image.png'), 'module/arg/whatever', array(), NULL, NULL, FALSE, TRUE)
How about a shorthand function i()?
i($image_path, $attributes=array(), $path, ...)
A "translation" function that behaves much like l(), but instead for images and image links.
Parameters
- $image_path
- Either the path of the image file (relative to base_path()) or a full URL.
- $attributes
- An associative array of HTML attributes to apply to the image tag (see theme_image()).
- $path
- The Drupal path being linked to, such as "admin/node". Can be an external or internal URL.
- ...
- Any other attributes to apply to the anchor tag (see l()).
So we would have a easy remindable function to place image [links] in Drupal. Look how smart the above example could look like:
i('anypath/images/image.png', array(), 'module/arg/whatever')
Not convinced yet? Let's place an alt tag:
i('anypath/images/image.png', array('alt' => 'shorthand!'), 'module/arg/whatever')
kk, it's arguable if that alt attribute should belong to required arguments for this function, since it's indeed required for valid XHTML. But hey, I think you get the point!
Comments
Comment #1
sunSeems like noone else is intered in such a shorthand function.
Comment #2
rlhawk1 commentedI am!! I think it's a great idea!