Forums / Setup & design / Has anyone used multiple images in articles?

Has anyone used multiple images in articles?

Author Message

Conor Murray

Friday 30 April 2004 3:22:55 am

I'd like to use multiple images in news articles, as some of the articles I'll be using on a specific site are rather long. I suppose I would need to support up to 4 images or so in each article.

I can create a suitable class, but I'm not too clear how to go about templating for it; or will I have to modify the eZ engine? Any suggestions welcome!

Conor Murray

Language is a virus - William S Burroughs

Paul Forsyth

Friday 30 April 2004 3:26:36 am

If you use an xml text field, as all standard articles do, you should be able to add images to intro or body field.

Do you need to use your images in other places other than article content areas?

paul

--
http://www.visionwt.com

Conor Murray

Friday 30 April 2004 3:56:39 am

Ideally I'd like to insert images right-aligned with the top of each 3rd or 4th paragraph in the main text of the article. I've looked through the stock eZ templates for something like this, but I couldn't find anything.

A layout similar to what I'm trying to achieve can be seen on: http://news.bbc.co.uk/2/hi/business/3672389.stm (not an eZ Publish site) - this example has just 2 pictures.

I supppose there are two ways this could be achieved:
1 - count the paragraphs outputted and use a modulus function to insert images (if available) in the correct locations.
or a more powerful solution:
2 - use some sort of tag embedded in the text to indicate where pictures should be inserted. I suspect this approach would be trickier to accomplish than 1.

Conor Murray.

Language is a virus - William S Burroughs

Paul Forsyth

Friday 30 April 2004 4:10:17 am

The problem you will have with either of these approaches is that it is not possible to separate out paragraphs in the xml text field. You have a field that contains everything.

To do this you would need to add your images to your article as related objects, and then include them within your xml text field. This is the only way i can see to get the article text to wrap correctly around the image at the right place. In a way this is actually the same as your tag idea, only that it is done within the admin and not in the template.

Have you tried the admin way?

Ez, is there a way to extract the paragraphs from an xml text field in the template?

paul

--
http://www.visionwt.com

Conor Murray

Friday 30 April 2004 7:23:09 am

I could probably override ezxmltext.tpl (a one-line template) with something a bit more complex that actually examines the data stream. I'm not sure how easy this will be, but that's what I'm looking at presently. It seems to be the most obvious place to attempt it!

As regards the admin approach, while adding related items is easy, I can't see how I can pull them into the text area. Am I missing something here?

Another aspect to the admin approach that is worrying is that it could raise the editorial complexity considerably - so I think I'll stick with the template-oriented approach for now.

Thanks for the help... I'll let the forum know how I get on if I can get it to work!

Conor Murray.

Language is a virus - William S Burroughs

Muhammad Khalid Majeed

Tuesday 04 May 2004 1:02:32 am

Hi Conor Murray,

I am also need to display the article same as you want. Please reply if you have find any solution for it.
Or if anybody else knows this solution.

Muhammad Khalid
Software Engineer
www.webgurru.net

Mark Gilbert

Tuesday 04 May 2004 5:29:05 am

OOOpppsss ... I thought this would work. On my live site it created a link instead of the actual image. You may be able to take an idea from here that will get you closer. Or you might need to create a custom tag. Click here for the details

http://ez.no/ez_publish/documentation/customization/components/datatypes/ezxmltext/custom_tags

Yes it is already built into eZ Publish. I am not sure which version it was added, either 3.2 or 3.3.

Do you have a "Media" tab in your administration interface? Click on it and upload your image. If you do not have a "Media" tab in the Admin then you will need to upgrade to a more recent version of eZ Publish.

Once you have added the image to "Media" tab, click on it and take note of the "Object ID". You need the Object Id NOT the Node ID.

In your article you can insert this code directly into an XML text field - <object id="591" />

You may need to do some additional work to control the placement of the image.

You can also navigate to this image from the edit view of the article. When you are in the edit view of an article on the right hand side of the page you will notice "Related Objects". In that box you will see a magnifying glass. Click on it. This will take you to a page that looks like a modified version of your "Content" tab. The difference is that you can select objects that you want to add to your XML text fields. Now from this modified page you CAN NOT use the tabs at the top to navigate. Instead you will see a box on the right hand side titled: "Top Levels&#8221; and below the title: &#8220;Switch top levels by clicking one of these items." You have to click these links to navigate instead of the tabs at the top of the page. If you click the tab at the top you will lose the ability to select an object. Navigate to the object you would like to add to your article and select it.

Once you have clicked the "Select" button you will return to the Edit Article View. In the related objects box you will notice the image you selected and an html tag similar to: <object id="591" />. Paste this tag into your article and your image now appears in your article.

Conor Murray

Tuesday 04 May 2004 9:17:35 am

Well, after a bit of kernel hacking I gave that up as a bad idea... so after some browsing around the eZ site I finally grasped what Paul Forsyth had suggested... I didn't realise that I could embed objects in the XML fields. This approach really makes the use of the OE (Online Editor) almost mandatory, as my end-users wouldn't be too happy with having to do this manually. So I threw $99 in eZ's direction and grabbed a copy of OE.

My current output templates show the images as links, as Mark states, but the Admin interface shows them perfectly in the browse view, so I guess I just need to tweak the templates a little bit. (Mark seems to have figured out how to do all of this without OE)

OK, so this solution is far from perfect, as it means that the images being used in the XML fields have to be uploaded as separate objects within eZ and then set up as related items before they can be embedded, which is a bit clunkier than I'd like.

Incidentally, before anyone rushes out and grabs OE, it has introduced a small client-side issue (MS Office setup launches in IE6 the first time it accesses a page with OE) - I'll ask about that in the Install & Config forum. It's not a huge deal, but it would be nice if it didn't happen... it also happens on the OE demo pages on the eZ site if anyone's curious in testing whether it happens to them (you need to attempt to edit an object with an XML field in it). I've verified that this problem occurs on 3 different PCs.

Thanks for the help folks ;-)

Conor Murray

Language is a virus - William S Burroughs

Plamen Petkov

Wednesday 05 May 2004 2:35:18 am

Use related objects, as suggested above. However, since related <object> tags ar displayed as links, you have to override the content/view/embed.tpl template for image clas (5 by default):

-=-= settings/siteaccess/xxx/override.ini.append
### Embeded Images: embed_image.tpl displays the image itself, not the link
[embed_image]
Source=content/view/embed.tpl
MatchFile=embed_image.tpl
Subdir=templates
Match[class]=5
-=-=

Play with embed_image.tpl (use the original embed.tpl as a starting point) and make it suitable for your needs: use attribute_parameters array to pass parameters: alaignment, size, href, captions... anything related to proper image display and embeding into XML text field.

Usage: <object id="<your image OBJECT ID>" param1="blabla" param2="blabla" />

At the time I write this it comes to my mind that, for backward comapatibility, there could be a parameter for whether the image is to be displayed or just the link to the object... Just another idea... Perhaps, by default, it must be set to "linkonly" (current eZ behavior)

-=-=-= this is my embed_image.tpl, uses the eZ core.css classes
{let image_variation="false"
align="center"
clearallbefore=false()
clearallafter=false()
href=""}

{*
New params:
clearallbefore, clearallafter: insert <br clear=all> before/after the image

New "align" type: pure : do not put the image in div, do not align, just display it
*}


{section show=is_set($attribute_parameters.size)}
{set image_variation=$object.data_map.image.content[$attribute_parameters.size]}
{section-else}
{set image_variation=$object.data_map.image.content["medium"]}
{/section}

{section show=is_set($attribute_parameters.align)}
{set align=$attribute_parameters.align}
{section-else}
{set align="center"}
{/section}

{section show=is_set($attribute_parameters.href)}
{set href=$attribute_parameters.href}
{section-else}
{set href=""}
{/section}


{section show=$attribute_parameters.clearallbefore}<br clear=all>{/section}


{switch match=$align}
{case match="left"}
<div class="imageleft">
{section show=$href}<a href={$href|ezurl}>{/section}
<img src={$image_variation.full_path|ezroot} />
{section show=$href}</a>{/section}
<div style="width: {$image_variation.width}px;">
{$object.data_map.caption.content.output.output_text}
</div>
</div>
{/case}
{case match="right"}
<div class="imageright">
{section show=$href}<a href={$href|ezurl}>{/section}
<img src={$image_variation.full_path|ezroot} />
{section show=$href}</a>{/section}
<div style="width: {$image_variation.width}px;">
{$object.data_map.caption.content.output.output_text}
</div>
</div>
{/case}
{case match="pure"}
{section show=$href}<a href={$href|ezurl}>{/section}
<img src={$image_variation.full_path|ezroot} />
{section show=$href}</a>{/section}
{/case}
{case}
<div class="imagecenter">

{section show=$href}<a href={$href|ezurl}>{/section}
<img src={$image_variation.full_path|ezroot} />
{section show=$href}</a>{/section}
<div style="width: {$image_variation.width}px;">
{$object.data_map.caption.content.output.output_text}
</div>
</div>
{/case}
{/switch}

{section show=$attribute_parameters.clearallafter}<br clear=all>{/section}

{/let}

Conor Murray

Saturday 08 May 2004 10:48:22 am

Plamen's template has just one flaw - though it's not Plamen's fault (thanks for the nice template code!). This is that the image caption is rendered via ezxml, so it's in <p> tags and will use the same style as the main paragraphs of text in the item it's embedded in, which is not really what you normally want in your output... usually caption text should have a style that sets it apart from the article text.

Another thing... we probably don't really want any styles that were used in the image object to show in the caption in the embedded image

{$object.data_map.caption.content.output.output_text} needs to be tweaked slightly to remove any xhtml tags so that we can apply our own style. The easiest way to do this is to use a modified 'wash' operator. Modifying this is described in http://www.ez.no/ez_publish/documentation/customization/tips_tricks/clean_html_tags (see my note at the foot of that page, it is still pertinent).

So the line will become something like this:
<p style="my_style">{$object.data_map.caption.content.output.output_text|wash(tag)}</p>

A final thing to remember is to note the fact that eztemplatestringoperator.php has been modified, or the captions will break the next time eZ is updated!

Language is a virus - William S Burroughs

Terry Grossman

Thursday 01 July 2004 6:20:46 pm

Hmm...in order to solve the fact that the caption text style is the same as the rest of the article text, couldn't you take the code that does this

<div style="width: {$image_variation.width}px;">
{$object.data_map.caption.content.output.output_text}
</div>

and add in a class'ed div for the caption

<div style="width: {$image_variation.width}px;">
<div class=captiontext>
{$object.data_map.caption.content.output.output_text}
</div>
</div>

and then define your caption text style changes via css:

.captiontext {
font-variant: small-caps;
text-transform: uppercase;
font-weight: bold;
font-size: smaller;
}

Terry

Bjarte Lunde

Tuesday 27 July 2004 4:39:43 am

I have a little problem when trying the <object id="xx">
When i put this in an article it cuts the article..
Do you know why?

Frederik Holljen

Tuesday 27 July 2004 11:34:09 pm

Does this happen regardless of what image/file you are embedding? Check the HTML for errors, maybe you have changed a vital template causing unbalanced tags.

Bjarte Lunde

Wednesday 28 July 2004 6:57:19 am

I'm using the news template

Edwin Casimero

Tuesday 21 September 2004 10:39:48 am

I am an EZP 2.2.x fan.
I am still frustrated with EZP 3.x because of this multiple image posting issue.

In EZP 2.2.x, I can just do:

<image 1 right medium #>
<image 2 center large #>
<image 3 float small #> <image 4 float small #> <image 5 float small #>

Is there a solution for EZP 3.x so that multiple image posting will be as easy as 2.2.x?

EZ Publish Loyalist since EZP 1.x
http://www.filipinowebservices.com

Frederik Holljen

Tuesday 21 September 2004 11:17:17 am

Actually you can do something very similar in eZ publish 3. You simply embed an image object using the "object" tag.

<object id="object_id_number"
        [ align="left|right|center" ]
        [ size="small|medium|large" ]
        [ class="test"              ]
        [ view="embed|text_linked"  ]
        [ href="destination_url"    ]
        [ target="_self|_blank"     ] />

Any image object will do.

willy jansen

Thursday 23 September 2004 7:52:06 am

for some reason this doesnt work for me

i included

<object id="143" size="small" align="center" />

in the article (object 143 does exist)

in the html source i find some empty tags

<div class="object-center">
        <div class="content-view-embeddedmedia">
    <div class="class-image">

    <div class="attribute-image">

                            <p>
</p>
        </div>

    <div class="attribute-caption" style="width: px">
        
    </div>

    </div>

anybody know what is going wrong? (i use ezpubli 3.4)

willy jansen

Thursday 23 September 2004 8:21:55 am

somehow <object id="123" /> doesnt return an image

with template debugging turned on i get this information

<!-- START: including template:
design/standard/templates/content/datatype/view/ezxmltags/object.
tpl
(design/standard/templates/content/datatype/view/ezxmltags/object
.tpl) -->
<p
class="small">design/standard/templates/content/datatype/view/ezx
mltags/object.tpl</p><br/>
<div class="object-center">
<!-- START: including template:
design/plain/override/templates/embed/image.tpl
(design/plain/override/templates/embed/image.tpl) -->
<p
class="small">design/plain/override/templates/embed/image.tpl</p>
<br/>
<div class="content-view-embeddedmedia">
    <div class="class-image">
    <div class="attribute-image">
                            <p>
<!-- START: including template:
design/standard/templates/content/datatype/view/ezimage.tpl
(design/standard/templates/content/datatype/view/ezimage.tpl) -->
<p
class="small">design/standard/templates/content/datatype/view/ezi
mage.tpl</p><br/>
<!-- STOP: including template:
design/standard/templates/content/datatype/view/ezimage.tpl
(design/standard/templates/content/datatype/view/ezimage.tpl) -->
</p>
        </div>
    <div class="attribute-caption" style="width: px">
<!-- START: including template:
design/standard/templates/content/datatype/view/ezxmltext.tpl
(design/standard/templates/content/datatype/view/ezxmltext.tpl)
-->
<p
class="small">design/standard/templates/content/datatype/view/ezx
mltext.tpl</p><br/>
<!-- STOP: including template:
design/standard/templates/content/datatype/view/ezxmltext.tpl
(design/standard/templates/content/datatype/view/ezxmltext.tpl)
-->
    </div>
    </div>
</div>
<!-- STOP: including template:
design/plain/override/templates/embed/image.tpl
(design/plain/override/templates/embed/image.tpl) -->
    </div>
<!-- STOP: including template:
design/standard/templates/content/datatype/view/ezxmltags/object.
tpl
(design/standard/templates/content/datatype/view/ezxmltags/object
.tpl) -->

seems ezxmltext.tpl doesnt pass through the correct info.
what could be the problem here? missing files? wrong file
permissions?

willy jansen

Tuesday 28 September 2004 9:00:49 am

the problem has been solved. the image with id 123 wasn't correctly in the filesystem