I have set a default product image under the cck/imagefield options at:
/admin/content/node-type/product/fields/field_image_cache
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'])) {
Comments
Comment #1
jacobkdavis CreditAttribution: jacobkdavis commentedComment #2
jacobkdavis CreditAttribution: jacobkdavis commentedI 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?
Comment #3
knd CreditAttribution: knd commentedWould 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.
Thanks
Comment #4
jacobkdavis CreditAttribution: jacobkdavis commentedI'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:
I modified the $imagelink = ''; line to be:
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!
Comment #5
cristian.stoica CreditAttribution: cristian.stoica commentedSubscribing
Comment #6
inteldesk CreditAttribution: inteldesk commentedHow about a Patch?
Comment #7
jnettikNot 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?
Comment #8
longwaveThis 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
Comment #9
jrussell CreditAttribution: jrussell commentedFollowing 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.
I added the folowing before the If (file_exists($path))
sites/default/files/imagecache/product_list/files/default_product.jpg is the path to your default image
Comment #10
chinita7 CreditAttribution: chinita7 commentedThanks #9 works for http://drupal.org/node/1493040
I'm using UC 6.x-2.7
Comment #11
deaftone CreditAttribution: deaftone commented#9 doesn't work for me. There should be a better way than hardcoding the image path.
Comment #12
longwaveAnyone 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.
Comment #13
iantresman CreditAttribution: iantresman commentedNot 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.Comment #14
iantresman CreditAttribution: iantresman commentedOK, 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.
Comment #15
iantresman CreditAttribution: iantresman commented