Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#277 2014-10-06 22:38:27

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 783
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

Bloke wrote #284575:

Past that I’m equally stumped. If you’ve tried all of the above and it’s not playing ball, feel free to drop me a login if the project is web-accessible and I’ll see if I can help you figure it out.

Your turn … I’ve send you an email. Don’t look at the mess …

Last edited by RedFox (2014-10-06 22:40:37)

Offline

#278 2014-10-07 08:23:52

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,742
Website GitHub

Re: smd_thumbnail: manage multiple thumbnails of your images

RedFox wrote #284576:

Your turn … I’ve send you an email. Don’t look at the mess …

What mess? Looks fine to me!

Thanks for the login. I traced the issue to a combination of the following:

  1. Though the unnecessary form attribute on the <txp:images> tag wasn’t a problem as such, it seemed to be confusing something, because when I took it out it began to play better. Dunno why.
  2. Your mobile folder only had two images in it (ids #6 and #8). You could see this when you edited an image. You have five profiles set up but only four thumbnail images were showing on the Image Edit panel for most images. When I used smd_thumbnail’s Tools/Prefs tool to recreate all thumbnails, the mobile folder was populated with all the images.

The error’s now gone. Hope that helps.


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

#279 2014-10-07 10:32:56

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 783
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

Bloke wrote #284580:

Your mobile folder only had two images in it (ids #6 and #8). You could see this when you edited an image. You have five profiles set up but only four thumbnail images were showing on the Image Edit panel for most images. When I used smd_thumbnail’s Tools/Prefs tool to recreate all thumbnails, the mobile folder was populated with all the images.

The error’s now gone. Hope that helps.

Sure, it helps a lot … thanks Stef. But … to understand smd_thumbnail correctly: all folders (profiles) have to contain all and the same thumbnails (IDs)? And must all individual pages (images) have all the thumbnails rendered? Or … when is smd_thumbnail in trouble … !?

Offline

#280 2014-10-07 11:07:16

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,742
Website GitHub

Re: smd_thumbnail: manage multiple thumbnails of your images

RedFox wrote #284581:

all folders (profiles) have to contain all and the same thumbnails (IDs)?

Yes. Each profile is a sub-folder in your images folder. For every database image that you upload/create, smd_thumbnail expects one file per profile to exist with the ID of the original image.

It creates thumbs for all active profiles when you upload images and, for the most part, this works fine. Depending on your smd_thumbnail prefs it’ll also try and keep things in sync when you make changes.

If you disable a profile and upload images, then later re-enable it, you’ll find some ‘holes’ in your thumbnail arsenal. That’s what the Tools/Prefs area is for: to allow you to re-synchronise everything.

smd_thumbnail will only try to access files for profiles which you mention in your <txp:smd_thumbnail> tag. So if you have holes anywhere, they only show up if you try and access that particular image. In your case, the random selection was falling foul of the fact you only had two images in that profile so in the majority of cases, it was failing to find one for the ID it had randomly chosen.

Here’s a good tip (which I keep forgetting to document properly and make clear in the alert box that pops up) : if you have a lot of profiles, you can cut down the amount of unnecessary work the plugin has to do during a resync by temporarily disabling any profiles you know hold a ‘complete’ set of IDs. The mass-resync then only affects the group of images you have chosen and only tries to recreate those files in any active profiles. With many profiles, the amount of disk activity is slashed and your resync completes in a fraction of the time.

Does that answer your question or do I need to give some more detail?


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

#281 2014-10-07 12:30:21

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 783
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

That implicates that if I choose to delete a thumbnail from an individual page (image) I must know (and now I know) that I can only do that if I instruct smd_thumbnail to render a new one … or to upload a new, homemade image (thumbnail). If not then someday I will be in trouble …

Thanks again Stef … you’re a tremendous help.

Offline

#282 2014-10-07 13:10:09

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,742
Website GitHub

Re: smd_thumbnail: manage multiple thumbnails of your images

RedFox wrote #284584:

That implicates that if I choose to delete a thumbnail from an individual page (image) I must know (and now I know) that I can only do that if I instruct smd_thumbnail to render a new one … or to upload a new, homemade image (thumbnail).

Yes, in a way. Removing an article image ID from an article won’t affect your page output as long as you’ve wrapped any <txp:images> tags in <txp:if_article_image>. Failure to do this will result in all images being shown when there are no article images. Alternatively turn off the auto_detect feature of <txp:images> so it doesn’t try to look in your article image field, though you’ll need to then specify exactly which images you want it to use.

Deleting physical images from your Images panel will indeed remove all images and thumbnails for all profiles, and your template will issue a warning, in exactly the same way as trying to view a normal missing thumbnail.

You can keep smd_thumbnail in sync with Txp’s internal thumbnails by setting a pref in the plugin. That means if you delete or add a physical image, a corresponding Txp thumbnail will also be removed or created to stay in step. This has the advantage that if you uninstall the plugin you have fallback images, but sometimes you might not want this if your Txp thumbnails are custom cropped/edited. That’s why it’s an option.

If you have this turned on and wish to have a fallback in your Page, you can employ <txp:variable> to capture the output of <txp:smd_thumbnail> and display it if it exists, else try a regular <txp:thumbnail> tag.


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

#283 2014-10-07 17:41:03

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 783
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

I wrote: “…to delete a thumbnail from an individual page (image)…” but I had to write: “to delete a thumbnail from the (an) individual page of an image…”
I didn’t mean an article image … but nevertheless your post makes both cases clear … :)

Last edited by RedFox (2014-10-07 17:42:02)

Offline

#284 2015-02-17 18:53:38

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

An smd_thumbnail snippet for those who want to do responsive images using the img / srcset / sizes combo.

In your form or page template:

<txp:images>
  <img src="<txp:smd_thumbnail type='xs-rect' display='url' id='<txp:image_info type="id" />' />"

    srcset="<txp:smd_thumbnail type='xs-rect' id='<txp:image_info type="id" />' form="img-srcset" />,
            <txp:smd_thumbnail type='sm-rect' id='<txp:image_info type="id" />' form="img-srcset" />,
            <txp:smd_thumbnail type='md-rect' id='<txp:image_info type="id" />' form="img-srcset" />,
            <txp:smd_thumbnail type='lg-rect' id='<txp:image_info type="id" />' form="img-srcset" />"

    sizes="(min-width: 1200px) 1140px,
           (min-width: 992px) 940px,
           (min-width: 768px) 720px,
           calc(100vw - 20px)"

   alt=""
/>
</txp:images>
<!--  img-srcset form -->
<txp:smd_thumbnail_info item="url" /> <txp:smd_thumbnail_info item="w" />w

Of course, you have to tune your srcset and sizes attributes to what you are trying to achieve.
Here is an excellent article on the topic:
ericportis.com/posts/2014/srcset-sizes/

See also:
scottjehl.github.io/picturefill/

Edit: forgot to add a wrapping <txp:images> that would provide the necessary image id (<txp:image_info type="id" />) that is “fed” to <txp:smd_thumbnail id="..." />. Added alt attribute too.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#285 2015-02-17 21:23:13

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

Hey Maniqui, that is so very apt and helpful. Thank you very much.

Offline

#286 2015-02-20 11:48:03

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,553
Website GitHub Twitter

Re: smd_thumbnail: manage multiple thumbnails of your images

@maniqui

Thanks for that, I was just about to do exactly this kind of thing! You might want to add an alt attribute in your example though.

Offline

#287 2015-02-20 12:57:11

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

You are right, Phil. I always forgot that damned alt attribute.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#288 2015-04-06 19:32:33

ploinkr
Member
From: Montreal
Registered: 2007-12-06
Posts: 83

Re: smd_thumbnail: manage multiple thumbnails of your images

Hi everyone, long time I’ve been here :)
Which version should I use for a site running 4.3.0?
Thanks.

Offline

Board footer

Powered by FluxBB