Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-01-14 14:34:01

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

url of article_image

I need to parse the url of the article_image in an xml file. Does anybody know if the code below will work or if not, can somebody suggest a method?

<txp:site_url />/images/<txp:images><txp:image_info id='<txp:custom_field name="article_image" />' />.<txp:image_info type="ext" /></txp:images>

The reason I am not checking it myself is that I am yet to have any content in the db yet

Edited to add that I will also need the extension of the image on a separate identifier in the xml file… Any ideas?

Re-edited as I think that I answered my second question

<txp:images id='<txp:custom_field name="article_image" />'><txp:image_info type="ext" /></txp:images>

Last edited by colak (2015-01-14 15:00:57)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#2 2015-01-14 14:44:09

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Re: url of article_image

As I understand it <txp:site_url /> will include a trailing slash, so you could trim back to:

<txp:site_url />images/<txp:images><txp:image_info id='<txp:custom_field name="article_image" />'.<txp:image_info type="ext" /></txp:images>

…to avoid the // after the site URL. As for the rest, I’ve got a bit of time free so I’ll have a look shortly.

Offline

#3 2015-01-14 14:45:48

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

Re: url of article_image

Yiannis, turn image_info into image_url (though I myself often think it should be image_info type="url") and close that tag (it’s open ATM), and it should work in an article form.

Edit: Ah, Pete’s of course right about the slash!

Edit 2: Oh dear, can be real bullsh…, sorry, but I can’t concentrate, been sick for too long now.

Last edited by uli (2015-01-14 15:11:07)


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

Offline

#4 2015-01-14 15:05:44

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: url of article_image

uli wrote #287366:

Yiannis, turn image_info into image_url (though I myself often think it should be image_info type="url") and close that tag (it’s open ATM), and it should work in an article form.

Edit: Ah, Pete’s of course right about the slash!

Woops you are right that it is indeed open and of course Pete is also right re the slash. I am not sure as to how I could replace info with url in as much as I can not see how I would add it to the code for txp to recognise what image I want to parse.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#5 2015-01-14 15:12:03

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

Re: url of article_image

colak wrote #287368:

I am not sure as to how I could replace info with url in as much as I can not see how I would add it to the code for txp to recognise what image I want to parse.

:) See my edit 2


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

Offline

#6 2015-01-14 18:57:46

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

Re: url of article_image

Are you explicitly trying to get the separate parts of the image name?

If so, you can use type="id" and type="name" with txp:image_info.

If you just want to get the proper image_url, and assuming your article image field holds an ID#, I’d place the article_image id in the wrapping txp:images tag and use txp:image_url like uli suggested:

<txp:site_url />images/<txp:images id='<txp:custom_field name="article_image" />'><txp:image_url /></txp:images>

BTW: uli: hope you get well soon!


TXP Builders – finely-crafted code, design and txp

Offline

#7 2015-01-14 21:25:02

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

Re: url of article_image

jakob wrote #287386:

BTW: uli: hope you get well soon!

Thanks, Julian, that sets me up. Honestly! :)


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

Offline

#8 2015-01-15 06:43:08

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: url of article_image

Yep that was it! Thanks so much guys. No it was not it as image_url gets the whole of the url so the answer is much simpler:

<txp:images id='<txp:custom_field name="article_image" />'><txp:image_url /></txp:images>

Last edited by colak (2015-01-15 07:08:41)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#9 2015-01-15 21:27:54

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

Re: url of article_image

Ah, I should have thought of that. That also means you can hone still further. I usually use txp:images with the id-article-image trick when there are several image tags within in. Here you just have one tag so you can use txp:image_url’s own id attribute directly:

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

TXP Builders – finely-crafted code, design and txp

Offline

#10 2015-01-16 07:01:21

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: url of article_image

You are right of course!


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB