Textpattern CMS support forum

You are not logged in. Register | Login | Help

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

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 740
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: 8,674
Website

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: 740
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
Moderator
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: Farnham, Surrey, UK
Registered: 2009-06-11
Posts: 3,196
Website

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
Moderator
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

#289 2015-04-06 21:06:09

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,207

Re: smd_thumbnail: manage multiple thumbnails of your images

ploinkr wrote #289789:

Which version should I use for a site running 4.3.0?

For severe security reasons you should NOT[!] run 4.3.0! Use at least 4.4.1, IIRC nothing will break, admin side. Most secure is using the current version, though (4.5.7, some manual puttying required should you have a customized back-end).

That said, compare these two lists wisely in order to find the correct versions:

TXP release dates smd_thumbnail release dates


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#290 2015-04-07 01:57:51

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

Re: smd_thumbnail: manage multiple thumbnails of your images

Thank you @uli, I will look into that!!

Offline

Board footer

Powered by FluxBB