Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-01-31 11:33:12

rossharvey
Member
From: Earth. Sometimes.
Registered: 2005-03-16
Posts: 233
Website

Get the URL of article_image (without a plugin)

Hi guys,

How can I do this? upm_image isn’t working for me in 4.4.1.

Is there something similar to this:

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

I tried using article_image_url (worth a pop), but to no avail.

Offline

#2 2012-01-31 12:16:38

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: Get the URL of article_image (without a plugin)

Core code:

<txp:images>
    <txp:image_url />
</txp:images>

In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#3 2012-01-31 12:20:14

rossharvey
Member
From: Earth. Sometimes.
Registered: 2005-03-16
Posts: 233
Website

Re: Get the URL of article_image (without a plugin)

If I use that exact code within an article, will it know I mean the article_image?

Offline

#4 2012-01-31 12:24:33

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,947
Website GitHub

Re: Get the URL of article_image (without a plugin)

rossharvey wrote:

If I use that exact code within an article, will it know I mean the article_image?

Yes, if you have one set (the default auto_detect is to check article image first). If there’s a chance you’ll leave article image empty, beware that code will display all your images. To defend against that, wrap Uli’s code with <txp:if_article_image>.

Last edited by Bloke (2012-01-31 12:25:07)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2012-01-31 12:31:23

rossharvey
Member
From: Earth. Sometimes.
Registered: 2005-03-16
Posts: 233
Website

Re: Get the URL of article_image (without a plugin)

Works perfectly – thanks very much guys!

Offline

Board footer

Powered by FluxBB