Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2008-10-09 12:39:35
- lee
- Member
- From: Normandy, France
- Registered: 2004-06-17
- Posts: 831
Get image id?
Anyone know a tag to return the image id used in the article image box in the write tab please?
best wishes
Lee
Offline
Re: Get image id?
Nope, but this should do the trick:
<txp:php>echo $GLOBALS['thisarticle']['article_image'];</txp:php>
Offline
#3 2008-10-09 13:37:45
- lee
- Member
- From: Normandy, France
- Registered: 2004-06-17
- Posts: 831
Re: Get image id?
Thanks very much, could I trouble you to get it to return the txp assigned file name and not just the id:) Please
So for example:
33.jpg and not 33
28.gif and not 28
Offline
Re: Get image id?
I think this will return the image URL.
<txp:php>echo preg_replace('/^.*?src="([^"]+)".*$/', '$1', article_image(array()));</txp:php>
And if it does, this should return the filename:
<txp:php>echo preg_replace('/^.*?src="[^"]*?([^"\/]+)".*$/', '$1', article_image(array()));</txp:php>
Last edited by ruud (2008-10-09 18:07:11)
Offline
Re: Get image id?
I thought upm_image could do both tasks: return the image ID and the file extension. But I’m looking at the help and it seems there isn’t any tag to return the file extension.
Offline
#6 2008-10-09 15:55:52
- lee
- Member
- From: Normandy, France
- Registered: 2004-06-17
- Posts: 831
Re: Get image id?
Hi Rudd, the two snippets don’t return anything at all for me.
Hi Julián, thanks for the help.
Offline
Re: Get image id?
Edited earlier post, it contained an error.
Offline
#8 2008-10-09 17:49:29
- lee
- Member
- From: Normandy, France
- Registered: 2004-06-17
- Posts: 831
Re: Get image id?
Hi Rudd, thanks for your time; both snippets give the article id.
Offline
Re: Get image id?
Third attempt (this happens when you write code without testing).
Offline
#10 2008-10-09 18:45:51
- lee
- Member
- From: Normandy, France
- Registered: 2004-06-17
- Posts: 831
Re: Get image id?
Thank you Rudd, your help is much appreciated – working perfectly.
Offline
Pages: 1