Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2010-09-28 20:16:32

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,424
Website GitHub

Re: [howto] Using the new image tags in Txp 4.3.0

Oh pants, maybe it won’t work then, sorry for getting your hopes up. Just threw it out there without trying it.

bad dev *spank*

Last edited by Bloke (2010-09-28 20:16:45)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#17 2010-09-28 20:20:51

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

Re: [howto] Using the new image tags in Txp 4.3.0

the_ghost wrote:

Where can we vote for width/height attrs for thumbnails? :)

Bloke wrote:

No need

Do you have to do something to your image library to get it to output height and weight attributes with the thumbnail tag, or are there flags in the tag itself?

Offline

#18 2010-09-28 21:17:52

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,424
Website GitHub

Re: [howto] Using the new image tags in Txp 4.3.0

johnstephens wrote:

Do you have to do something to your image library to get it to output height and weight attributes with the thumbnail tag, or are there flags in the tag itself?

By default it’ll output width= and height= attributes in the <img> tags. You can now override that with width and height attributes on the txp:thumbnail (as of r3411), txp:image and txp:article_image tags. Thus you can force the dimensions if you wish, or let the borwser scale one or both of the dimensions. width="0" or height="0" will omit the output of that particular value and let the browser scale the dimension instead of reading it from the database.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#19 2010-09-28 21:25:54

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

Re: [howto] Using the new image tags in Txp 4.3.0

Bloke wrote:

By default it’ll output width= and height= attributes in the <img> tags. You can now override that with width and height attributes on the txp:thumbnail (as of r3411), txp:image and txp:article_image tags. Thus you can force the dimensions if you wish, or let the borwser scale one or both of the dimensions. width="0" or height="0" will omit the output of that particular value and let the browser scale the dimension instead of reading it from the database.

I must have done something wrong. I’m looking at output from txp:thumbnail and it includes only src, alt, and title— no width or height. I thought I might have to go into the image tab and re-save each thumb to get the heights and widths in the database, or something like that.

Also, offset doesn’t seem to work work when using image_list in an article form when the article image contains comma-separated image ids; I get the same image list with or without offset. Is that correct, or have I done something wrong?

Offline

#20 2010-09-28 21:31:50

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,424
Website GitHub

Re: [howto] Using the new image tags in Txp 4.3.0

johnstephens wrote:

I thought I might have to go into the image tab and re-save each thumb to get the heights and widths in the database, or something like that.

Ah yes, you do. Sorry, I’m being a dimwit tonight. If you don’t have thumbnails assigned, the database won’t have a record of their dimensions so you’ll get nothing out by default. But you can still force the size with the width and height attributes.

Also, offset doesn’t seem to work work when using “image_list”

Hmmm, I’ll look into that. Thought I tested it, but maybe it fell by the wayside somehow. I’ll see if I can test that particular functionality later.

Last edited by Bloke (2010-09-28 21:32:09)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#21 2010-09-28 21:40:48

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

Re: [howto] Using the new image tags in Txp 4.3.0

johnstephens wrote:

I thought I might have to go into the image tab and re-save each thumb to get the heights and widths in the database, or something like that.

Bloke wrote:

Ah yes, you do. Sorry, I’m being a dimwit tonight. If you don’t have thumbnails assigned, the database won’t have a record of their dimensions so you’ll get nothing out by default. But you can still force the size with the width and height attributes.

What’s the bounty on a script that can update your textpattern’s image table to include the height & width information without manually re-saving each one? ;)

johnstephens wrote:

Also, offset doesn’t seem to work work when using “image_list”

Bloke wrote:

Hmmm, I’ll look into that. Thought I tested it, but maybe it fell by the wayside somehow. I’ll see if I can test that particular functionality later.

My thought was that the image ids of the Article Image field were overriding the offset.

Thanks for the awesome release candidate, BTW.

Offline

#22 2010-09-28 21:44:16

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,424
Website GitHub

Re: [howto] Using the new image tags in Txp 4.3.0

johnstephens wrote:

Also, offset doesn’t seem to work work when using “image_list”

Try adding a limit as a stop-gap. The problem is that by default the limit is 0 (“all”) which for reasons of vagaries in the code (line 2950 of taghhandlers.php) won’t actually trigger the offset to fire in the SQL. That should probably be changed but I think I tried it before and it fell apart under certain conditions. I could try again, or maybe someone else has some bright ideas.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#23 2010-09-28 21:47:16

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,424
Website GitHub

Re: [howto] Using the new image tags in Txp 4.3.0

johnstephens wrote:

What’s the bounty on a script that can update your textpattern’s image table to include the height & width information without manually re-saving each one? ;)

Free if you use smd_thumbnail :-)

Well, to be fair, it doesn’t update the TXP thumbs in the database but it creates as many new thumbs of arbitrary dimensions as you care to define. If you define just one you get the same functionality as TXP now. But there’s a natty Create All button in the plugin for just this situation.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#24 2010-09-28 22:03:27

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: [howto] Using the new image tags in Txp 4.3.0

johnstephens wrote:

What’s the bounty on a script that can update your textpattern’s image table to include the height & width information without manually re-saving each one? ;)

You can probably afford it:

soo_thumb_atts


Code is topiary

Offline

#25 2010-09-28 22:23:40

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

Re: [howto] Using the new image tags in Txp 4.3.0

Bloke wrote:

Try adding a limit as a stop-gap. The problem is that by default the limit is 0 (“all”) which for reasons of vagaries in the code (line 2950 of taghhandlers.php) won’t actually trigger the offset to fire in the SQL. That should probably be changed but I think I tried it before and it fell apart under certain conditions. I could try again, or maybe someone else has some bright ideas.

That works! Now I just have to figure out a way to add a limit equal to X-1 where X is the number of image ids provided. There must be a txp:variable way to do that. Thanks again!

jsoo wrote:

soo_thumb_atts

Awesome! Thanks!

Offline

#26 2010-09-28 22:31:35

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

Re: [howto] Using the new image tags in Txp 4.3.0

johnstephens wrote:

Now I just have to figure out a way to add a limit equal to X-1 where X is the number of image ids provided.

I take that back— providing a limit of any amount greater than or equal to the number of image ids works totally fine. (Just like the article tag, duh!) I could use the limit="99999" trick, but in this case 99 is more than enough.

Sorry for the slow draw, and thanks again!

Offline

#27 2010-09-29 03:37:10

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

Re: [howto] Using the new image tags in Txp 4.3.0

Last question of the night: Is there any way to specify an deliberate, non-systematic sort order in the image_list tag? soo_image used the order of the given image ids to sort the output, but image_list defaults to name asc.

For the case I’m testing, I just renamed the files, but I can see how this wouldn’t be ideal in other implementations.

Offline

#28 2010-09-29 08:11:36

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,424
Website GitHub

Re: [howto] Using the new image tags in Txp 4.3.0

johnstephens wrote:

Is there any way to specify an deliberate, non-systematic sort order in the image_list tag?

Not without some trickery. You can use the MySQL1 cheat:

sort='FIELD(ID,5,3,2,4,1)'

but that’s not much use if you need the order to be read from the article_image itself. Now, if you were using a custom field then it’s easy:

sort='FIELD(ID,<txp:custom_field name="sort_order" />)'

But as I found to my detriment last night, the article_image field can’t just output its raw values: it always makes an image tag out of its content. Perhaps this is the last obstacle we need to address to make image handling complete: some way to tell article_image to output either:

  • the full <img> tag as normal from either the ID, name, or URL in the field
  • the fully qualified URL of its (sole) content
  • the raw value(s) in the field itself — like a custom field

I seem to remember having a go at doing this at the time I did the image_list system but failed to make it robust enough/useful/not confusing. If anybody wants to have a go at doing this quick-smart then it would be a useful fix as I think that’s the last area where upm_image outshines the new core tag suite.

1 Please note that this is a MySQL feature only (as far as I’m aware) which is not a problem now, but may be in the future of TXP if we start to support other DBs.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#29 2010-09-29 10:10:49

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,559
Website GitHub Twitter

Re: [howto] Using the new image tags in Txp 4.3.0

Bloke a écrit:

sort='FIELD(ID,<txp:custom_field name="sort_order" />)'

But as I found to my detriment last night, the article_image field can’t just output its raw values: it always makes an image tag out of its content. Perhaps this is the last obstacle we need to address to make image handling complete: some way to tell article_image to output either:

Hi Stef may be you can use article_image like this:

sort='FIELD(ID,<txp:custom_field name="article_image" />)'

must be work! (not tested)

Last edited by Dragondz (2010-09-29 10:12:58)

Offline

#30 2010-09-29 10:42:30

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: [howto] Using the new image tags in Txp 4.3.0

We’ve rather drifted away from the topic, so I’ve answered in the Images are 1st class citizens of TXP thread.


Code is topiary

Offline

Board footer

Powered by FluxBB