Forums / General / Display an image image within an XHTML attribute

Display an image image within an XHTML attribute

Author Message

James Robertson

Wednesday 07 September 2005 7:34:18 pm

I have a class called 'Article', that contains a text-block attributed called 'Body'. My intention is for the Body attribute to contain XHTML code. (This code my be entered through the admin interface using a drop-in replacement for the <textarea> field, such as HTML Area or FCKEditor.) I want to be able to insert an <img> tag within the Body XHTML that references an Image file stored within eZ publish.

Currently I am achieving this by inserting the <img> tag with it's src attribute pointing to, for example, '/images/my-image' (the eZ publish url_alias for the image file). On it's own, this would of course attempt to display the content/view for the Image object, rather than the image file itself. So I have overidden the pagelayout.tpl for Match[class_identifier]=image such that, the override template called an extension function, 'Redirect', that redirects to the image file (ie. $node.data_map.image.content.original.url).

Is there a better way to do this? I do not want to use the eZ publish XML datatype. [There is an existing text mark-up language called XHTML (You may have heard of it ;-) and I don't see why my users should have to leanr another one.]

One of the problems with my approach is that it can mess up the Preview in the admin interface, since I have not set up the same template override here. Also, I can not dynamically set the height and width attributes for the <img> tag.

What I would like to be able to do is insert a piece of eZ publsih template code within the XHTMl content of the Article/Body attribute (ie. {attribute_show_gui attribute=$image.data_map.image}) but I don't now how to get eZ publish to process template code that is embedded within an object attribute.

Cheers
JamesR

Ɓukasz Serwatka

Wednesday 07 September 2005 11:23:55 pm

Hi,

Look here
http://ez.no/community/forum/developer/is_any_way_to_enable_tags_p_font_span_in_articles

and

Here is an example how to add external images in to eZ XML field.
http://ez.no/community/forum/setup_design/custom_tag_not_working_with_a_link

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog