Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2007-01-19 09:04:16
- suckerfish
- New Member
- Registered: 2006-12-19
- Posts: 6
dynamically apply class to images
hi
i am trying to assign a class to certain images based on their category. at present i need to style the images based on their widths. i have tried using:
<txp:article_image <txp:if_category name=“wide”> class=“wide” </txp:if_category> />
but so far this outputs all images as class ‘wide’ regardless of the category they are in.
any suggestions?
Offline
#2 2007-01-19 09:21:33
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: dynamically apply class to images
<txp:if_article_category name="wide">
<txp:article_image class="wide" />
</txp:if_article_category>
- TextBook: if_category and if_article_category
- FAQ: Can I use tags within tags?
- Plugin: asy_wondertag
Offline
#3 2007-01-19 10:21:05
- suckerfish
- New Member
- Registered: 2006-12-19
- Posts: 6
Re: dynamically apply class to images
sorry. i think i phrased that badly. i am trying to do it using the image, rather than article category. is this possible?
Offline
#4 2007-01-19 10:49:43
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: dynamically apply class to images
…is this possible?
No, I don’t think you can with Txp’s built-in article images. You can do it with one of my plugins though (upm_image), using a custom form.
Last edited by Mary (2013-01-24 17:30:58)
Offline
#5 2007-01-19 11:27:29
- suckerfish
- New Member
- Registered: 2006-12-19
- Posts: 6
Re: dynamically apply class to images
sorry if i seem a little slow, but i’m fairly new to textpattern.
how would i go about creating the custom form?
i assume i would call it with <txp:upm_img_category /> but, where to from there?
Offline
#6 2007-01-19 11:44:19
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: dynamically apply class to images
In your article form, instead of using <txp:article_image />
you could do something like:
<txp:upm_article_image form="my_image_form" />
form, “my_image_form”:
<img class="<txp:upm_img_category />" src="<txp:upm_img_full_url />" width="<txp:upm_img_full_width />" height="<txp:upm_img_full_height />" alt="<txp:upm_img_alt />" title="<txp:upm_img_caption />" />
Offline
#7 2007-01-19 13:12:57
- suckerfish
- New Member
- Registered: 2006-12-19
- Posts: 6
Re: dynamically apply class to images
works a charm, thanks for all the help.
Offline