If no image is attached to a node, the teaser for the image will be a broken image-- looking at the source for the page, it outputs a img src to '/drupal/images/imagecache/image_teaser/' (or as appropriate to the installation), note just directory, no image file there.

See http://drupal.org/node/101748#comment-275116 for brief history.

Comments

jeff h’s picture

I can verify this is a problem. It can be fixed by adding the following to the top of the theme_imagecache_formatter function:

if (!$item['filepath']) {
return null;
}

But I believe this theme function should not even be called by the imagecache_field_formatter function if there is no image to generate HTML (ie theme) mark-up for in the first place. Perhaps that's what the first IF condition in imagecache_field_formatter() is trying to catch:

if (!isset($item['fid'])) {
return '';
}

...but for me, even empty image fields still have a fid.

jpetso’s picture

Status: Active » Closed (duplicate)

To me, this sounds like a duplicate of this imagefield issue (starting with comment 20 or so). This is fundamentally broken in 5.x-1.x, you should upgrade to imagefield 5.x-2.x (together with imagecache HEAD) and I bet the problem disappears.

shrill’s picture

Hi. I'm having the same problem and I'm using the latest version of imagefield, and 5x.2.1 of imagecache.

Is there a solution? Where does one find theme_imagecache_formatter?

Thanks,

Shrill

liquidcms’s picture

Title: If no image attached, teaser displays [X] (broken image) under IE, bullet under Firefox » imagecache theme fnuction doesn't work with default images.
Version: 5.x-1.3 » 5.x-2.1
Priority: Normal » Critical
Status: Closed (duplicate) » Active

i can confirm this issue still exists.

i have 2.1 version of imagefield which i patched to get default imgs working in general and now defaults work with imagecache when part of a normal node page.. but when called in a tpl using the theme('imagecache') function the default img paths are not created properly.

same as above, i only get the path to the preset folder for the img src

i changed title, since not even close to being right.. lol

and not duplicate of issue above.. so changing that as well

liquidcms’s picture

Title: imagecache theme fnuction doesn't work with default images. » imagecache theme function doesn't work with default images.
liquidcms’s picture

i can see now that the imagefield is not built for the node when it has no image and therefore nothing downstream (like imagecache has anything to work with)

i tried sorting out where the bug is that i am sure is in imagefield (or possibly cck) but gave up.. so i simply added this "hack" into my tpl that is creating my psuedo-teaser:

// add this to make up for bug in imagefield/cck modules that can't handle default imgs when called from theme function
if (!$product->field_image[0]['filepath']) $product->field_image[0]['filepath'] = "files/imagefield_default_images/field_image.jpg";

$product_img = theme('imagecache', 'product_plp_teaser', $product->field_image[0]['filepath'], $product->field_image[0]['alt'], $product->field_image[0]['title'], null);

this lets icache do the right thing and build the required folders for the new default img for this preset

btw, as i stated earlier.. if the node is being created as the std full node or likely as a real teaser i am sure the node would be built correctly in which case the node object would have the image field (set to full size default img that is uploaded for the field) and then this would work correctly..

Maxkupr’s picture

The better way is

		if (!isset( $node->field_product_logo[0]['filepath'] )) {
			$field = content_fields('field_product_logo');
			$node->field_product_logo[0]['filepath'] = $field['default_image'];;
		}

as for me.
cause you don't know extention of file (it may be png, gif, etc.)

hixster’s picture

subscribing

1kenthomas’s picture

Priority: Critical » Major
Status: Active » Closed (won't fix)

closing; assuming no further support. Correcting priority as well :P