Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-08-20 12:03:22

stopsatgreen
Member
Registered: 2008-07-03
Posts: 50

[solved] article_image URL only

I want to change the background image of a page using the associated article_image, but I can’t find a way to output the URL only. I’ve taken a look at hak_article_image and that doesn’t seem to do it either. What I want is something like this:

.element { background-image: url(‘<txp:article_image />’); }

But as far as I can see there’s no way to not output the <img src=”“ /> around the result.

Last edited by stopsatgreen (2008-08-22 23:37:21)

Offline

#2 2008-08-20 12:29:46

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: [solved] article_image URL only

element { 
  background-image: url('<txp:php>
      echo htmlspecialchars($GLOBALS['thisarticle']['article_image']);
    </txp:php>');
}

Note that this only works as inline CSS, because style sheets aren’t parsed for TXP tags.

Offline

#3 2008-08-20 13:14:32

stopsatgreen
Member
Registered: 2008-07-03
Posts: 50

Re: [solved] article_image URL only

Hmmm… that’s almost there, but maybe I’m missing a step.

I have this code in the <head> of my page, because I don’t want to include the whole thing inside the article form:

.centre_panel { background-image: url('images/<txp:article_custom form='article_img' limit='1' />.jpg'); }

And this is the form article_img:

<txp:php>echo htmlspecialchars($GLOBALS['thisarticle']['article_image']);</txp:php>

What happens is that all pages show the most recent article_image, and not the one associated to the page. Can you see why that might be?

Offline

#4 2008-08-20 13:30:23

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: [solved] article_image URL only

Why don’t you simply put my code in the HEAD of the page?
Either that or use <txp:article /> instead of <txp:article_custom /> :)

Offline

#5 2008-08-20 13:38:07

stopsatgreen
Member
Registered: 2008-07-03
Posts: 50

Re: [solved] article_image URL only

Using <txp:article /> has resolved the issue, thanks.

Any idea if this is being considered as a change to the <txp:article_image /> tag; something like:

<txp:article_image type='link' />

Offline

#6 2009-01-09 06:09:14

lous
Member
From: Germany
Registered: 2009-01-04
Posts: 57

Re: [solved] article_image URL only

Hello,
ive make a form called “img-url”

<txp:php>echo htmlspecialchars($GLOBALS[‘thisarticle’][‘article_image’]);</txp:php>

And in my article_list form ive put this code to show the image

<a href=”<txp:article form=‘img-url’ limit=‘1’ />” “target=”_blank”<txp:article_image style=“float:left; margin-right:15px; border:0; width:169px” /></a>

The image shows up perfectly, BUT my goal is to put the img url of each img as href.

End it just shows the url of the latest img and not of the current img of this article.

This is how my List is looking like:

Title

—————————————————————————————

1. Article_Img + Only the first article_Img URL

—————————————————————————————

2. Article_Img + Only the first article_Img URL

—————————————————————————————

And thats my goal:

Title

—————————————————————————————

1. Article_Img + 1. article_Img URL

—————————————————————————————

2. Article_Img + 2. article_Img URL

—————————————————————————————

Would be soo nice, if someone could help.
Thanks soo much in advance

Offline

#7 2009-01-13 06:05:21

lous
Member
From: Germany
Registered: 2009-01-04
Posts: 57

Re: [solved] article_image URL only

so no one can help me? :(

Offline

#8 2009-01-13 06:43:59

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: [solved] article_image URL only

lous wrote:

so no one can help me? :(

Can :) Replace your <txp:article form='img-url' limit='1' /> -tag with the code that you have inside the img-url form.

Thus we get for example:

<a href="<txp:php> echo htmlspecialchars($GLOBALS['thisarticle']['article_image']); </txp:php>" "target="_blank">
	<txp:article_image style="float:left; margin-right:15px; border:0; width:169px" />
</a>

Last edited by Gocom (2009-01-13 06:44:14)

Offline

#9 2009-01-14 21:27:20

lous
Member
From: Germany
Registered: 2009-01-04
Posts: 57

Re: [solved] article_image URL only

Thanks a lot Gocom :)

Offline

#10 2009-01-14 21:45:49

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,596
Website

Re: [solved] article_image URL only

Bit late here but if you have upm_image installed, it includes a tag <txp:upm_img_full_url /> that outputs just the url.


TXP Builders – finely-crafted code, design and txp

Offline

#11 2013-07-12 13:33:38

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: [solved] article_image URL only

If it can still help someone this is what I use (txp tags only).

In my image_url form :
<txp:image_url id='<txp:custom_field name="article_image" />' />

and then, my article form :
<txp:variable name="image_url" value='<txp:output_form form="image_url" />' />
<div style='background-image:url(<txp:variable name="image_url" />)' />Your content…</div>

That’s it.

Last edited by NicolasGraph (2013-07-12 15:46:21)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#12 2013-07-12 14:13:00

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: [solved] article_image URL only

And why not simpler?

<div style="background: url(<txp:image_url id='<txp:custom_field name="article_image" />' />) no-repeat; min-width: ??px; min-height: ??px;">Your content</div>

Offline

Board footer

Powered by FluxBB