You are here: Home / What do you need? / Help and documentation / Plone Info / Missing images in portal_factory

Missing images in portal_factory

by Darrell Kingsley last modified Mar 13, 2014 02:23 PM
Images in the browser images resource folder are called with ++resource++my.theme.images/image-name.png. This works perfectly except in portal_factory. Here's how to fix it.

With a theme or other Plone 3+ product with a browser directory, resources such as images are called using ++resource++my.theme.images/image-name.png. But when you are creating a new bit of content e.g. a new web page, the portal_factory doesn't render these properly and gives an error:

BadRequest: The id "++resource++bb.networks.images" contains characters illegal in URLs.

This litters up the log and the missing images don't look that good for our clients when they come to create content. The way round it is to include the full URL of the image in the src attribute of the image. This involves adding a tal:attributes call to the image tag in the template as follows:

tal:attributes="src string:${context/portal_url}/++resource++my.theme.images/image-name.png"

This only needs to be done for macros or code used in portlets and viewlets which will then be displayed with the portal_factory template i.e. header and footer and left and right column content. It does not need to be added to templates that are displayed as part of the main content, as these will be replaced by the portal_factory templates.