Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-07-31 12:25:11

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

display image alt text as wide as thumbnail

my code:

in article:

<txp:images id=“74” form=“right” />

form “right”:

<a class="single right" href="<txp:image_url />" title="<txp:image_info type="caption" />"><txp:thumbnail /><span class="thumb-alt" width="<txp:image_info type="thumb_w" />"><txp:image_info type="alt" /></span></a>

this way i managed to get a fixed width to a span tag in html, but it doesn’t work. so i have to specify span width with css, like i did right now. but i need a fluid width because thumbs are different in size.

or maybe there is a better solution/code, cause this not perfect anyway (doubled alt text)?

Last edited by Gallex (2013-08-01 07:51:31)

Offline

#2 2013-07-31 13:08:14

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: display image alt text as wide as thumbnail

In HTML5, there is no global attribute width. Width is specific to images, form input and frames etc. It doesn’t work anywhere else.

If you want to set width, you will have to use CSS:

<a style="width: <txp:image_info type="thumb_w" />px;" href="<txp:image_url />" title="<txp:image_info type="caption" />">
    <txp:thumbnail />
    <span class="thumb-alt"><txp:image_info type="alt" /></span>
</a>

Offline

#3 2013-08-01 05:32:36

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,393
Website

Re: display image alt text as wide as thumbnail

@ Gallex

As Gocom notes, the width attribute only applies to certain elements (form controls, replaced elements such as images), use inline style instead.

Second, your stylesheet already specifies max-width: 180px for the span.thumb-alt. That would override any width to you would set if larger than 180px.

There are no good solutions that would allow you to omit the width in your situation where the captions are quite long.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

Offline

#4 2013-08-01 11:05:32

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

Re: display image alt text as wide as thumbnail

hei guys, gocom’s tip is a good solution, it’s doing what i wanted! only thumbs always has to have width set. thank’s!

Last edited by Gallex (2013-08-02 06:33:07)

Offline

Board footer

Powered by FluxBB