Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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: 11,269
Website GitHub

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,470
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!


BB6 Band My band
Gud One My blog

Offline

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

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

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,470
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

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


BB6 Band My band
Gud One My blog

Offline

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

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
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.


BB6 Band My band
Gud One My blog

Offline

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

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

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,470
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?


BB6 Band My band
Gud One My blog

Offline

#21 2010-11-10 10:35:28

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

Re: smd_thumbnail: manage multiple thumbnails of your images

zero wrote:

Feasible?

I think so. Will see if I can find time to fix it today.

No point having cake if you can’t eat it :-)

Last edited by Bloke (2010-11-10 10:35:57)


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

#22 2010-11-10 11:25:31

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

Re: smd_thumbnail: manage multiple thumbnails of your images

Creating a TXP thumb at the same time as the default profile thumb is created seems trivially easy. Untested at the moment but I just wrote the code to do it and don’t foresee any issues (famous last words).

Question: what happens when you delete a thumbnail designated as the default profile? Should it also delete the TXP thumb, or leave it alone? My gut instinct says to delete it as well, even though that will kill <txp:article_image thumbnail="1" /> and <txp:thumbnail /> tags. After all, if you delete a thumb from TXP’s regular interface then that has the same effect.

Everyone concur or have I got it wrong?


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

#23 2010-11-10 11:34:19

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

Re: smd_thumbnail: manage multiple thumbnails of your images

I’d say don’t delete the txp thumb. Replace it by all means with a new default profile thumb, but is it doing any harm if it is not deleted from the images folder?

EDIT: I don’t mean automatically replace txp thumb with new default profile thumb, but only replace it if user chooses to do so.

Last edited by zero (2010-11-10 11:41:23)


BB6 Band My band
Gud One My blog

Offline

#24 2010-11-10 11:53:14

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

Re: smd_thumbnail: manage multiple thumbnails of your images

zero wrote:

I’d say don’t delete the txp thumb. Replace it by all means with a new default profile thumb, but is it doing any harm if it is not deleted from the images folder?

OK, I can see where you’re coming from. And it’s less code :-) It does no harm leaving it alone.

only replace it if user chooses to do so.

Oh, right. I figured the TXP thumb should automatically track the default profile. If not, how would this choice be indicated? Given that:

  1. I don’t have any prefs (though I could probably find somewhere to house a single tickbox, it’s a lot of extra code)
  2. Clicking to Create All just goes and does it (no dialog can be offered as the only choices are OK/Cancel… and Cancel always does just that)
  3. Uploading a new image, creating a thumb (in Edit mode) or replacing an existing image automatically fires the creation routine with no further user interaction possible

I could offer a hidden pref I suppose for those that can be bothered to create one: that’s the simplest route for me but not the prettiest solution. The point is, either way it’d be a global on/off switch so has to apply to all actions. Hmmmmm.

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


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

Board footer

Powered by FluxBB