Closed (fixed)
Project:
Imce CCK Image
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
25 Jun 2008 at 23:55 UTC
Updated:
6 Nov 2009 at 02:12 UTC
The image path is empty when an image hasn't been set for the field, but yet markup is rendered.
This is a quick and dirty patch to stop rendering of markup (both IMG and A) if the path is empty.
It is a temporary solution since it's not well thought through but please review it and consider fixing this issue with the next release.
--- imceimage/imceimage.module.old 2008-06-26 01:22:36.000000000 +0200
+++ imceimage/imceimage.module 2008-06-26 01:26:43.000000000 +0200
@@ -198,6 +198,7 @@ function imceimage_widget(&$form, &$form
* theme an image
*/
function theme_imceimage_image($s, $w='', $h='', $a='', $id='') {
+ if(empty($s)) return '';
$s = 'src="'. $s .'" ';
$a = 'alt="'. $a .'" ';
$id = !empty($id)? 'id="'. $id .'" ':'';
@@ -212,6 +213,7 @@ function theme_imceimage_image($s, $w=''
**/
function theme_imceimage_formatter_link($element) {
$item = $element['#item'];
+ if(empty($item['imceimage_path'])) return '';
return '<a href="'. base_path() . $item['imceimage_path'] .'" class="imceimage-link">';
}
| Comment | File | Size | Author |
|---|---|---|---|
| imceimage_module_hide_empty_field_6_x-1_x-dev.patch | 711 bytes | Danial Namousi |
Comments
Comment #1
Danial Namousi commentedPlease note that you can achieve this by simply overriding the functions in your theme.
Edit: This approach stops the image from being shown when creating/editing a node, which is unsatisfactory.
Comment #2
panis commentedfixed in head. uses Danial's approach - but inserts a blank 1x1 image if there is no image..
Comment #3
panis commentedfixed in head. uses Danial's approach - but inserts a blank 1x1 image if there is no image..
Comment #4
saborchulo commentedDanial is correct. My approach was overriding the default registered theme function responsible (theme name is masters), perhaps this is something that can be implemented in the default registered theme function. It's much cleaner then diving into the core code for the module, IMO.
Basically if no path is set when creating a content type that this field is associated with just return nothing as the output. Works perfectly.
Comment #5
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #6
ssm2017 Binder commentedhello
i did like that :
Comment #7
zoltán balogh commentedPlease, do not insert a blank 1x1 image if there is no image. Original Danial's solution is a good choice. If there is not an image, always return empty string.
In other case, the label of the imce image field is always displayed, and if the imce image is alone in the fieldgroup, the empty fieldgroup with only the label also displayed. This is not a good solution.
So, if there is not an image, then return empty.
Comment #8
yang_yi_cn commentedI'd like to suggest a different approach:
change the function theme_imceimage_formatter_default($element) from
to
As my site addes a css border to the image, when there's an empty image, it will show the bare border, which is not good. My solution doesn't show the placeholder at all thus solves the problem.
Comment #9
panis commentedfixed