Closed (duplicate)
Project:
ImageField
Version:
5.x-1.1
Component:
Code
Priority:
Critical
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
27 Jul 2007 at 20:17 UTC
Updated:
14 Dec 2007 at 15:19 UTC
I have a custom content type that uses imagefield so a user can upload an image.
I created a new view page and made a table that shows all of these nodes. It shows the nodes title as well as a thumbnail (imagecache) of the image that the user uploaded.
If the user did not upload an image then views is printing broken images (since there is no actual image to print)
How can I fix this?
Comments
Comment #1
merlinofchaos commentedImagefield generates those links in handlers that it provides to Views.
Comment #2
j0k3z commentedThanks for a quick response.
So what can I do? If a user has not uploaded an image can views provide a default image somehow?
Comment #3
gregglesI see a couple options:
1. Make the image field required (though I imagine that won't work, but at least it's easy)
2. Use a views theme function - http://drupal.org/node/128741
3. A new feature in the formatters that provides a default image if no image was selected. I know that I've needed this before and I got around it with a theme fix (complex and I no longer have the code, so I can't/won't provide it - besides, it's not the good way to fix the problem).
Comment #4
moshe weitzman commentedI have needed this too. I love #3 - formatter feature. But does the formatter even get called when there is no value?
Comment #5
moshe weitzman commentedimagefield 5.2 will have default image support. it is already in CVS, but apparently uploading the default image is broken ATM. I don't know how well the default image is integrated with Views. The formatter would be lovely.
Comment #6
moshe weitzman commentedI figured out why this does not work. Now I just need some help finding the right fix. Our formatter receives "incomplete" data when called from a View as compared to called during a node_view(). Specifically, it performs this test before emitting a default image:
elseif ($field['widget']['use_default_image'] && is_array($field['widget']['default_image'])) {The problem is that
$field['widget']only contains a 'label' element. It has no 'use_default_image' so the test fails and nothing gets emitted.Comment #7
jpetso commented'widget' members are not supplied by views, and probably shouldn't be. In filefield, I recently needed to migrate a remotely similar setting from hook_widget_settings() to hook_field_settings() because it's not a widget setting really. (Also, $field can be read by the formatter, $field['widget'] can't.)
I might be wrong, but the default image doesn't really sound like it should be a widget setting, does it? Anyways, you don't have lots of possibilities to get $field['widget'] from the formatter.
Comment #8
ms2011 commented@moshe weitzman: Re. imagefield.module: Everything we need is already provided by views.
KarenS explains here:
http://drupal.org/node/117621
Patch for imagefield.module is here:
http://drupal.org/node/180592#comment-658982
Comment #9
moshe weitzman commentedok, lets follow the patch at http://drupal.org/node/180592.