Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-10-31 19:28:18

sparkybarkalot
Member
Registered: 2004-10-13
Posts: 43

Article Image Question

I’m trying to find a way to build a path to an article image, but can’t find an elegant way to do it. Here’s the situation:

I’ve got a lightbox image gallery that is working just fine, but the code is a bit clunky in one spot, wondering if anyone has any suggestions on how to clean this up. The rel=”“ part of my link looks like this in my form:

rel=”/<txp:php>echo $GLOBALS[‘prefs’][‘img_dir’];</txp:php>/<txp:php>echo $GLOBALS[‘thisarticle’][‘article_image’];</txp:php>.jpg”>

It works just fine, but you can see that I had to hard-code the .jpg part, which is kind of clunky, and I’m thinking there’s got to be a better way of doing this. Is there some built-in way in TXP to do this, or can anyone recommend a plug-in that would do the trick? I’ve tried a few plug-ins with no success. I’m using Mary’s upm_image and thought that it might help me with this (since it seems to do just about anything) but no luck figuring it out.

Any suggestions? Thanks much!

Offline

#2 2007-10-31 20:58:31

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: Article Image Question

<txp:upm_image><txp:upm_full_img_url /></upm_image> perhaps?

Doesn’t lightbox just pull the path from the href? Or is this not actually lightbox you are using?


Shoving is the answer – pusher robot

Offline

#3 2007-10-31 21:02:13

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Article Image Question

Your original code should work fine this way.
rel=”/<txp:php>echo $GLOBALS[‘prefs’][‘img_dir’]; echo $GLOBALS[‘thisarticle’][‘article_image’];</txp:php>.jpg”>

Offline

#4 2007-10-31 21:13:04

sparkybarkalot
Member
Registered: 2004-10-13
Posts: 43

Re: Article Image Question

Thanks for your replies.

hakjoon:
I miswrote that. It’s not for a lightbox, the rel=”“ is used by a bit of javascript to make the article image appear on hover elsewhere on the page… so your suggestion doesn’t apply at the moment

rsilletti:
That does clean things up a bit more, and I’ll definitely use it. I’m still hoping I don’t have to hardcode the .jpg part in there as well. Hoping there’s something out there like $GLOBALS[‘thisarticle’][‘article_image’] but which also includes the file extension.

Thanks for that. Anyone have any more ideas too?

Offline

#5 2007-10-31 23:03:16

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Article Image Question

If you use a URL (or anything non-numeric) in the article image field, whatever you enter as text will be passed as the image value including the extension. At any rate – so long as you are using the numeric entry in the article image field you are going to have to ask the system for the extension from the database (I believe) to automate the process. The full entry in the article image field might work best.

Offline

#6 2007-11-01 15:09:22

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: Article Image Question

The question is if you are using image ID’s in the article image field or not. If not you have to specify the whole thing.

If you are using ID’s this should give you the url for the full image in the rel attribute which seems to be what you want. My previous example should have upm_article_image not upm_image

rel="<txp:upm_article_image><txp:upm_full_img_url /></upm_article_image>"

Of course Rick’s code works too.


Shoving is the answer – pusher robot

Offline

#7 2007-11-01 17:35:09

sparkybarkalot
Member
Registered: 2004-10-13
Posts: 43

Re: Article Image Question

rsilletti: thanks for the suggestion, i ended up using hakjoon’s method since upm_image did what i needed without the muss and fuss.

hakjoon: that was totally the ticket! Once i figured out that there were a few typos in your suggestion it all came together finally.

The solution is:

rel=”<txp:upm_article_image><txp:upm_img_full_url /></txp:upm_article_image>”

Thanks very much for the help!

Offline

Board footer

Powered by FluxBB