Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#73 2010-12-16 10:19:53

Niconemo
Member
From: Rhône-Alpes, France
Registered: 2005-04-18
Posts: 557

Re: smd_thumbnail: manage multiple thumbnails of your images

Sorry, probably not going to happen as the underlying (TXP core) function needs to store the physical dimensions and the plugin can’t rewrite profiles on the fly.

OK. I was prepared to your answer. Here is the solution I found (with some smd_if too, of course) to avoid the use of the image_info :

<txp:variable name="hauteur-image" value='<txp:upm_article_image><txp:upm_img_full_height /></txp:upm_article_image>' />
<txp:variable name="largeur-image" value='<txp:upm_article_image><txp:upm_img_full_width /></txp:upm_article_image>' />

<txp:smd_if field="txpvar:largeur-image" operator="gt:NUM" value='<txp:variable name="hauteur-image" />'>
      <txp:smd_thumbnail type="Wide" />
<txp:else />
      <txp:smd_thumbnail type="Tall" />
</txp:smd_if>

Thank you again !

Last edited by Niconemo (2010-12-16 10:20:13)


Nico

Offline

#74 2010-12-16 12:38:30

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

Re: smd_thumbnail: manage multiple thumbnails of your images

Niconemo wrote:

to avoid the use of the image_info

Out of curiosity, why avoid it? Does it not do what you want? If you take the category attribute out of the <txp:images> tag in the code I posted then I think it does exactly the same as your code (because <txp:images> automatically reads the article image if you use no attributes), and it’s shorter.


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

Online

#75 2010-12-16 13:48:29

Niconemo
Member
From: Rhône-Alpes, France
Registered: 2005-04-18
Posts: 557

Re: smd_thumbnail: manage multiple thumbnails of your images

Well…

I think your’re right. In fact I read your code much too fast. I must admit, I discover the txp:image_info tag (Genealogy : Version 4.3.0 – tag introduced) and I was thinking about something completely different (some custom field or something…).

Your proposition is far better !


Nico

Offline

#76 2010-12-25 10:52:47

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

Mmm. First real effort at using this fantastic plugin and getting an error message:

Tag error:  <txp:smd_thumbnail type="large" /> ->  Textpattern Notice: Unknown image.  on line 1038

Profile name is “large”, the profile is active and there is another profile which is default. Even without the type attribute no thumbnails display and the error message persists. Mmm!

Edit: 4.3 install.

Last edited by jstubbs (2010-12-25 10:55:52)

Offline

#77 2010-12-25 11:16:06

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

OK solved it – the code needed the new txp:images></txp:images tag to retrieve the article image thumbnail:

<txp:images break=""><txp:smd_thumbnail type="large" /></txp:images>

Interestingly, before installing smd_thumbnail, just using <txp:thumbnail /> worked fine even with 3 images in the article image field (that in itself is a great addition to 4.3!) – TXP worked as expected by displaying the first article image in the field.

Offline

#78 2010-12-25 13:54:20

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

Somewhat tangential to my post above, on the entry for <txp:images /> on TextBook – the attribute auto_detect="" is a little unclear.

If you wish to turn off the automatic check, set this to auto_detect=”“….

Then later, it says something which appears to contradict that:

<txp:images auto_detect=”“ /> displays all images in the database.

I am using smd_thumbnail to display thumbnails entered in an article image field. Normally, this field might contain several images id’s, but in case there is nothing entered in the field so nothing should be displayed.

Using the following code (with nothing at all in the article image field), what I see is all images inside the database – did I miss an attribute setting?

<txp:images break="">
    	<li><a class="thumb" name="<txp:image_info type="name" />" href="<txp:image_url />" title="<txp:image_info type="name" />"><img src="<txp:image_url thumbnail="1" />" alt="<txp:image_info type="alt" />" /></a>
			<div class="caption">
				<div class="image-desc"><txp:image_info type="caption" /></div>
			</div>
		</li>
    </txp:images>

Offline

#79 2010-12-25 14:12:39

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

Re: smd_thumbnail: manage multiple thumbnails of your images

jstubbs wrote:

auto_detect="" is a little unclear.

OK, I can fix the documentation — it’s still WIP. Though it is true: the default is auto_detect="article, category, author" which will automatically check if there is a) something in the ‘article image’, b) a category list page in effect, c) an author list page in effect. So if you shut this off with auto_detect="" then it won’t look in those places.

Against my better judgement, but to fit in with all the other tags, the default operation is to display all items if nothing is detected (or other filter attributes are used, such as category, id, author, realname, etc). Since the act of shutting off auto_detect means the tag won’t even bother being clever and looking for anything, it has the net effect of returning all images. Not my first choice of behaviour, but it’s what the linklist and file_download_list tags do (erroneously, imho). I feel tags should, by and large, be opt-in rather than opt-out.

…in case there is nothing entered in the field so nothing should be displayed.

Yes, you’re hitting the same issue as above. I dont like it much, but that’s where <txp:smd_if_thumbnail /> comes into play.


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

Online

#80 2010-12-25 14:46:53

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

Tags should definitely be opt-in – that’s good behaviour IMO.

Looks like <txp:smd_if_thumbnail /> needs to be used in a form – I get an error using this on a page:

<txp:article limit="100">
<txp:if_individual_article>
	<txp:output_form form="portfolio_gallery" />
<txp:else />
	<div class="portfolio">
		<txp:permlink class="portfolio_item">
			<txp:smd_if_thumbnail>
				<txp:images break=""><txp:smd_thumbnail type="large" /></txp:images>
			</txp:smd_if_thumbnail>
		</txp:permlink>
		<txp:excerpt />
	</div>
</txp:if_individual_article>
</txp:article>   

Error message:

Tag error:  <txp:smd_if_thumbnail> ->  Textpattern Notice: Image tags cannot be used outside an image context  on line 2312

Am I right?

Offline

#81 2010-12-25 15:01:59

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

OK well that’s not the cause of the error because I use the following code on another page and see all of the images in the database – and there is no image attached to the article in question, same as the other page.

The error message does display though – in debugging at least.

<txp:article limit="1">
	<h2><txp:title /></h2>
	<txp:body />
		<txp:smd_if_thumbnail>
			<txp:images break=""><txp:smd_thumbnail type="large" /></txp:images>
		</txp:smd_if_thumbnail>
</txp:article>

Offline

#82 2010-12-25 15:10:59

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

Re: smd_thumbnail: manage multiple thumbnails of your images

jstubbs

Try this (untested) with the smd_if_thumbnail inside the images tag:

<txp:article limit="1">
	<h2><txp:title /></h2>
	<txp:body />
	<txp:if_article_image>
		<txp:images break="">
			<txp:smd_if_thumbnail>
				<txp:smd_thumbnail type="large" />
			</txp:smd_if_thumbnail>
		</txp:images>
	</txp:if_article_image>
</txp:article>

EDIT: to add if_article_image

Last edited by Bloke (2010-12-25 15:18:38)


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

Online

#83 2010-12-25 17:43:28

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

Thanks Stef. Interesting result – one code block brings an error but the other one does not, although in both cases there is no article image assigned.

In debug mode, this works in one section/page template without any error:

<txp:article limit="1">
	<h2><txp:title /></h2>
	<txp:body />
	<txp:if_article_image>
		<txp:images break="">
			<txp:smd_if_thumbnail>
				<txp:smd_thumbnail type="large" />
			</txp:smd_if_thumbnail>
		</txp:images>
	</txp:if_article_image>
</txp:article>

In the other section/page template (this is an article list, but I am testing the first article in the list which has no article image assigned), this code block also works but the error message displays:

<txp:article limit="100">
<txp:if_individual_article>
	<txp:output_form form="portfolio_gallery" />
<txp:else />
	<div class="portfolio">
		<txp:permlink class="portfolio_item">
			<txp:if_article_image>
				<txp:smd_if_thumbnail type="large">
					<txp:images break=""><txp:smd_thumbnail type="large" /></txp:images>
				</txp:smd_if_thumbnail>
			</txp:if_article_image>
		</txp:permlink>
		<txp:excerpt />
	</div>
</txp:if_individual_article>
</txp:article>

Error message is displayed 11 times – Tag error: <txp:smd_if_thumbnail type="large"> -> Textpattern Notice: Image tags cannot be used outside an image context on line 2312 – and there are 12 articles, so I guess the first article which has no image is not causing an error (on the list view page).

On the individual article page, using <txp:if_article_image> as a wrapper tag as in the above example does work correctly – it no longer retrieves all the images in the DB. Thanks for the tip!

Offline

#84 2010-12-26 14:14:14

debeljko
Member
From: Belgrade
Registered: 2007-07-02
Posts: 15
Website

Re: smd_thumbnail: manage multiple thumbnails of your images

Someone already mentioned that smd_thumbnail works with smd_gallery but i can’t get even simple form to work, why?

Here is what i have on page…

<txp:smd_gallery category="<txp:custom_field name="Galerija" />" limit="500"><txp:smd_thumbnail link_rel="prettyPhoto" link="1" /></txp:smd_gallery>

…and i get tihs error… <txp:smd_thumbnail link_rel="prettyPhoto" link="1" /> -> Textpattern Notice: Unknown image. on line 1038

Offline

Board footer

Powered by FluxBB