I have set a default product image under the cck/imagefield options at:


The ubercart catalog grid pages are not showing this default image for products without images.

I've done a "print_r($node)" to test from my node.tpl.php and I can see that the path for the default image is showing up there in field_image_cache[0]['filepath']. I don't know when this is getting set, but it seems that the problem is that when the grid is checking for images in uc_catalog.module in the theme_uc_catalog_product_grid function, this filepath field is not yet populated with the default image information.

Line 728:
if (module_exists('imagecache') && ($field = variable_get('uc_image_'. $product->type, '')) && isset($product->$field) && file_exists($product->{$field}[0]['filepath'])) {


jacobkdavis’s picture

Title:Ubercart catalog grid does not respect imagefield default image» Ubercart catalog grid does not show imagefield default image
Component:Catalog» Code
jacobkdavis’s picture

I was able to get around this for the time being by overriding the uc_catalog_product_grid function in my theme, but that feels like a bit of a hack. Is this really the only way to get a default image?

knd’s picture

Would you please elaborate on how you did that.I derived a book class and I dont see the default image on catalog(both grid and table),it is definitely not working anymore even on the full node page though it used to a few days ago.


jacobkdavis’s picture

I've had someone else ask me about this also so I figured I would respond here.

I overrode the following function from the uc_catalog.module file:
function theme_uc_catalog_product_grid($products) {

I pasted the whole function into my theme's template.php as a new function called phptemplate_uc_catalog_product_grid($products)

Under that function, I changed the following section:

    if (module_exists('imagecache') && ($field = variable_get('uc_image_'. $product->type, '')) && isset($product->$field) && file_exists($product->{$field}[0]['filepath'])) {
      $imagelink = l(theme('imagecache', 'product_list', $product->{$field}[0]['filepath'], $product->title, $product->title), "node/$nid", array('html' => TRUE));
    else {
      $imagelink = '';

I modified the $imagelink = ''; line to be:

    $imagelink = l(theme('imagecache', 'product_list', "sites/default/files/imagefield_default_images/no-image-available.gif", $product->title, $product->title), "node/$nid", array('html' => TRUE));

Where the no-image-available.gif is hard coded to be your default image.

Hopefully this helps out anyone else that is looking for a temporary fix for this!

cristian.stoica’s picture


inteldesk’s picture

How about a Patch?

jnettik’s picture

Not sure if this should be it's own thread or not but I'm having the same problem with the full node and teaser views of my products. I'm not using the catalog module. Has anyone experienced that?

longwave’s picture

Title:Ubercart catalog grid does not show imagefield default image» Ubercart does not show imagefield default image

This should be implemented for all places images are used, not just the catalog grid.

Marked #1493040: Default image is not displayed on cart pane. as duplicate

jrussell’s picture

Following jacob's lead I was able to similarly hack uc_product.module to workaround the missing cart default product images. I added an if statement to uc_product_get_picture to fill empty image paths with the hardcoded path to my default_product.jpg.

function uc_product_get_picture($node_id, $format = 'product') {
  $output = '';
  $product = node_load($node_id);

  if (!module_exists('imagecache') || !($field = variable_get('uc_image_'. $product->type, ''))) {
    return '';

  // Get the current product image widget.
  $image_widget = uc_product_get_image_widget();

  if (isset($product->$field)) {
    $image = $product->{$field}[0];
    $path = $image['filepath'];
    if (file_exists($path)) {
      $img = theme('imagecache', $format, $path, $image['data']['alt'], $image['data']['title']);
      if ($format == 'product') {
        if ($image_widget) {

I added the folowing before the If (file_exists($path))
if (!file_exists($path)) {
  $path = "sites/default/files/imagecache/product_list/files/default_product.jpg";
sites/default/files/imagecache/product_list/files/default_product.jpg is the path to your default image
chinita7’s picture

Thanks #9 works for http://drupal.org/node/1493040
I'm using UC 6.x-2.7

deaftone’s picture

#9 doesn't work for me. There should be a better way than hardcoding the image path.

longwave’s picture

Status:Active» Closed (won't fix)

Anyone who had this problem in 6.x will have lived with it or worked around it by now, and it isn't an issue in 7.x.

iantresman’s picture

Issue summary:View changes

Not quite, just encountered this issue myself in Ubercart 6.x-2.14, as Drupal 6.x hasn't been discontinued yet! So disappointed this hasn't made it into 6.x-2.x-dev.

I thought I could fix this in the imagefield Display fields, by changing from <hidden> to one of the image options, but was disappointed that this setting is used only to prevent the node for showing the image.

Update: It seems that #9 fixes the issue only in the cart. I thought it might also fix it for the individual product nodes which are also not showing default images. Unfortunately I can't figure out where this is generated, although it seems that function theme_uc_product_image has something to do with it, but I have no idea when it is called.

iantresman’s picture

Status:Closed (won't fix)» Active

OK, so it appears that the Ubercart /products page shows the imagefield default image, so I'm assuming that any defined View will do so too.

But any pointers how I can get a single Ubercart product node to show a default image, if none has been specified. Just to make matters harder, I am running a multisite, so I can't completely hard wire it by referring to a sites/defaut, but perhaps there is another way to tackle nodes?

Update: My fault, the product does display the default image. I mistakenly thought that Preview would show it, but I have to Save the node first.

iantresman’s picture

Status:Active» Closed (won't fix)