tags:

views:

26

answers:

1

The creative team wants to be able to use Zotonic to manage images used outside of the main website. In order to do this they are currently linking to images as follows:

<img src="http://example.com/media/inline/2010/10/29/image.jpg" />

This has a huge flaw. Every time an one of these images is replaced in Zotonic the filename can change. If the replacement happens on a different day the path to the file changes. This means that they have to replace the image in Zotonic and then update the HTML on the other sites as well.

Imagine that the Media item in question has ID 575. I would like to let them link to images as follows:

<img src="http://example.com/media/575" />

How do you link to a media item by ID outside Zotonic?

+1  A: 

After reading your question I made a small change to the resource_file_readonly and added two dispath rules:

{media_attachment, ["media","attachment","id",id], ... },
{media_inline, ["media","inline","id",id], ... }

Which allows an image tag like:

<img src="http://example.com/media/inline/id/575" />

This change is now available on the tip of the default branch (0.6-dev).

Marc W
Please note that files are served with caching headers, which means that it might take a while before visitors see image changes. That is the reason why (unique) filenames are used in the media tags.
Marc W
Good point on caching. Thank you Marc. The external pages are mostly one time visit pages so the caching should be largely harmless in our case.
Alain O'Dea