Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show the image of a Dexterity-based Plone content type in a listing view?

What's the best way to show the image of a Dexterity-based Plone content type in a listing view?

Say I have a folder with Dexterity-based content objects that provide an image field and I want to list the objects (as catalog brains) together with their image. It is possible to show the images in the listing by calling their absolute URL:

<img src="" tal:attributes="src string:${item/getURL}/@@images/image/thumb" />

Though, Plone will raise an error if the image does not exist and I don't see a good way to check if the image exists in a page template. We obviously do not want to wake up the objects for a listing, to look up the image.

Do I have to create an image metadata column in the catalog or is there a better solution I don't see?

like image 259
tisto Avatar asked Sep 20 '11 13:09

tisto


2 Answers

I wouldn't worry too much about waking up objects in a listing as long as it's properly batched. If you're using the fields from plone.app.textfield and plone.namedfile then large data is kept in separate persistent objects, so the main content item object is relatively lightweight. Of course, do your own benchmarking if you want to be sure it doesn't hurt for your case.

like image 125
David Glick Avatar answered Sep 30 '22 21:09

David Glick


There is a recipe for how to do this in Professional Plone 4 Development (chapter 10, I believe). Unfortunately, I genuinely can't remember how to do it right now. :)

like image 26
optilude Avatar answered Sep 30 '22 21:09

optilude