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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 20:00:52
Script start
Timing: Jan 19 2025 20:00:52
Module start 'layout'
Timing: Jan 19 2025 20:00:52
Module start 'content'
Timing: Jan 19 2025 20:00:52
Module end 'content'
Timing: Jan 19 2025 20:00:52
Script end

Main resources:

Total runtime0.0172 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0071 590.7109152.6406
Module start 'layout' 0.00710.0031 743.351639.4766
Module start 'content' 0.01010.0047 782.828189.3359
Module end 'content' 0.01480.0023 872.164134.3047
Script end 0.0171  906.4688 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.003017.6110140.0002
Check MTime0.00158.6555140.0001
Mysql Total
Database connection0.00074.339610.0007
Mysqli_queries0.003520.456330.0012
Looping result0.00000.094410.0000
Template Total0.002011.410.0020
Template load0.00116.423910.0011
Template processing0.00084.922810.0008
Override
Cache load0.00084.572810.0008
General
dbfile0.00031.656780.0000
String conversion0.00000.051440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs