Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2010-11-07 19:41:23

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,138
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

Great stuff, Stef! When I resize images it is usually the width, so I am using these types: t320, t240 etc to show me the width. As heights are often different, I don’t specify height and your plugin promptly scales them accurately. HTML then shows like: images/t320/22.jpg?1289149541" width="320" alt="ochre" class="t320" /> HTML5 doesn’t seem to mind not having a height specified any more. However, not having a height causes the image to load last and the page jumps down to accommodate it. (Don’t you just hate the many websites where you are just about to click a link and it jumps about?)

So my question is, is it possible for the plugin to autodetect the missing height or width and write it in the html?

Also, is the ?1289149541 necessary after the .jpg ?

Thanks for great work with plugins and of course Textpattern 4.3. Maaarvelous!!!


TXPQ Examples and discussion of Textpattern CMS quality.
Safe Reiki Harmless natural healing.

Offline

#12 2010-11-08 09:25:37

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,458
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

zero wrote:

is it possible for the plugin to autodetect the missing height or width and write it in the html?

I should think so. Makes sense, so leave it with me.

Also, is the ?1289149541 necessary after the .jpg ?

Not really, and I was in two minds whether to make this an option. When I was testing I was getting stale images showing up even when I’d changed the thumbs so that was a simple cache-busting mechanism. The downside of course is that it increases page download bandwidth. Perhaps I’ll turn that dubious ‘feature’ off and find some way (a hidden pref) that means you can globally turn it on or (perhaps also) add a tag option allow_cache="0" to add it on a per-thumb basis.

Thanks for the ideas and the kind words (oh, and sorry about the tag builder snafu re: deprecated attributes in 4.3.0: totally missed that, and entirely my fault).


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

Txp Builders – finely-crafted code, design and Txp

Offline

#13 2010-11-08 23:15:04

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

Perhaps I’ll turn that dubious ‘feature’ off and find some way (a hidden pref) that means you can globally turn it on or (perhaps also) add a tag option allow_cache=“0” to add it on a per-thumb basis.

Really very waiting for this :)


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#14 2010-11-09 17:01:05

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,458
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

zero wrote:

is it possible for the plugin to autodetect the missing height or width and write it in the html?

I had a go at this. Here’s the story:

  1. If you omit width/height the browser scales the missing dimension on page load
  2. We cannot rely on the database to have a thumbnail width/height since this plugin is a replacement for the built-in system
  3. Thus the only place we can get the missing dimension from is the image itself, which means reading the actual file
  4. If you have set a thumbnail dimension in your profile, created a thumb and subsequently altered the profile dimensions without recreating the thumbs, you will therefore get a distorted image

If you can live with that, try v0.11. I think it does what you want (EDIT: via the force_size attribute), but do holler if I’ve got the wrong end of the stick.

This version also removes the ?timestamp from the image by default. You can reinstate it with add_stamp="1". Note the timestamps are added to the admin-side images regardless because you want them to change when they are updated. The stamp only changes when the thumbs are recreated so I was wrong about the bandwidth earlier: it shouldn’t affect it at all, but it does look ugly so it’s now opt-in.

Also fixed a stupid oversight that re-fetched the image from the database when it didn’t need to. Much faster now inside <txp:images />.

Last edited by Bloke (2010-11-10 11:27:54)


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

Txp Builders – finely-crafted code, design and Txp

Offline

#15 2010-11-09 20:00:05

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,138
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

Not quite sure I understand number 3. If I create thumb profile ‘mid’ with dimensions 200 × 100, then create thumbnail, then I can see that thumbnail in ‘mid’ directory at 200 × 100. But if I then change ‘mid’ profile to 100 × 100 but don’t create thumbnail, on the webpage the thumbnail shows at 100 × 100 even though it is still 200 × 100 in directory. So what is browser reading?

But anyway, I can live with creating lots of profiles so thumbs have height and width in html, so thanks! Not sure what you did re height and width though, it seems the same :-\ Glad you found ways to save bandwidth and make it faster. Cheers!


TXPQ Examples and discussion of Textpattern CMS quality.
Safe Reiki Harmless natural healing.

Offline

#16 2010-11-09 20:22:35

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,458
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

zero wrote:

So what is browser reading?

It read the profile as you specified it. If you change it and don’t regenerate the thumbs then the browser will squish the thumbs to fit the dimensions you have explicitly set in the profile. If, however, you leave one of the width/height entries empty (or 0) then the plugin will leave that item empty in the <img> tag. To force it to put the ‘missing’ dimension in — as read from the file itself in the ‘mid’ directory — add force_size="height" (in your case, since you’re setting the widths).

To put it another way, if you have loads of thumbs of different heights — e.g. you set the width=320 and left height blank in the profile — then with force_size="height" you will get the height="whatever" in the <img> tag. Thus the browser knows the dimensions and can reserve some space for it on the page. If you omit the force_size attribute it behaves as before — missing the height= attribute.

Clear as London on a foggy day?

Last edited by Bloke (2010-11-09 20:24:17)


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

Txp Builders – finely-crafted code, design and Txp

Offline

#17 2010-11-09 21:10:12

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,138
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

AAAHHHH! Penny dropped. I had’nt seen the force_size attribute. Great! Thanks Stef.


TXPQ Examples and discussion of Textpattern CMS quality.
Safe Reiki Harmless natural healing.

Offline

#18 2010-11-09 22:55:08

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,138
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

Possible bug but it’s probably my misuse: <txp:article_image thumbnail="1" /> no longer seems to work, even though I have a thumbnail there and have selected a profile as a default. <txp:article_image /> works fine.


TXPQ Examples and discussion of Textpattern CMS quality.
Safe Reiki Harmless natural healing.

Offline

#19 2010-11-10 09:12:36

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,458
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

zero wrote:

<txp:article_image thumbnail="1" /> no longer seems to work

It won’t, unless you happen to have uploaded some thumbnails before you installed smd_thumbnail. At the moment, smd_thumbnail is a replacement (well, an addition really) for TXP’s thumb handling and as such does not interfere or otherwise tamper with the existing thumbs. I thought it was safer this way so that if (when?) you uninstall smd_thumbnail you at least have a baseline remaining.

In light of your comment, perhaps I’m wrong though. Maybe the default profile should also actually become the standard TXP thumbnails as well, so article_image thumbs still work. It would be less confusing I suppose and would then mean that if you uninstalled the plugin your most recent thumbs would still prevail. At the moment, things kind of drop back to how they used to be (just deactivate the plugin and then visit the Images panel to see what I mean).

I’ll look into the feasibility of making this happen, thanks for pointing it out.


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

Txp Builders – finely-crafted code, design and Txp

Offline

#20 2010-11-10 10:31:43

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,138
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

It was A direct replacement for the built in txp:thumbnail tag with exactly the same functionality and attributes apart from these exceptions that made my non-coder’s brain assume I would be able to get the best of both worlds and it would fit perfectly with existing tags that use thumbnail. If, for the default profile, it could copy the thumbnail into the images folder as say 22t as well as copying the thumbnail into the ‘mid’ folder as 22, then not only would we have cake but I think we’d also be able to eat it! And if there was already 22t there it would just overwrite it? Feasible?


TXPQ Examples and discussion of Textpattern CMS quality.
Safe Reiki Harmless natural healing.

Offline

Board footer

Powered by FluxBB