0

I have a File/Image CCK field with a default image set and the Use default image checkbox is checked. I am rendering this field in a view- but the default image does not show for nodes where an image has not been uploaded.

How do I get the default image to show in a view?

Ive tried re-uploading the image, re-setting the checkbox, clearing cache. FYI, if I do upload an image, it does show in the view.

Any further ideas?

  • This works here for me with Views 3 at least. One thing to note that might be different: if you add a field to a node type and there are nodes that are already created, these "pre-new field nodes" won't have the default set until you resave them. – Jimajamma Sep 9 '13 at 15:38
  • BTW, Im using Views 2. – Jono Sep 10 '13 at 7:42
  • Jimajamma, just tried that re-saving idea but it didnt work. The image field did exist before creation anyway. – Jono Sep 10 '13 at 7:49
  • Perhaps a work around could be achieved by rendering some alternative HTML in the view if the image field is empty? – Jono Sep 10 '13 at 7:50
  • If Views 2 has 'rewrite when empty' logic like Views 3, most definitely. Alas, I don't have a testbed to check if that is the case. But if it did/does, it would be an found when you click on the gear to change the other options of that field. – Jimajamma Sep 10 '13 at 11:58
0

OK. So my solution was to use Customfield to write some PHP to check if the image field is empty. If it is, then I output some HTML to render a default image. I had to hard-code the image URL which is not ideal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.