Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-02-13 16:51:34

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Get an image type

Hi community,

Sunday question: How do I get, output the the type of an image (jpg, png, gif) ?

Something like {ext} ?

Thanks.

Guillaume

Last edited by hablablow (2011-02-13 17:26:23)


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#2 2011-02-13 18:44:32

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Get an image type


Code is topiary

Offline

#3 2011-02-13 20:23:57

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: Get an image type

Thanks Jeff but unfortunately I’m using previous release, so can’t use the new image tags introduced in 4.3…

Any pre 4.3 method ?


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#4 2011-02-13 20:29:05

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

Re: Get an image type

If you are on 4.2, you can use smd_gallery.
If you are in even older versions, you could try to add this txp tip to your needs.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#5 2011-02-13 20:42:58

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: Get an image type

Thanks Julian…
Isn’t there a simple <php> snippet to do that ? smd_gallery could fit the bill but is a little big just to retrieve an image extension…


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#6 2011-02-14 15:02:32

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: Get an image type

In fact this is working

<txp:smd_gallery limit="1">{ext}</txp:smd_gallery>

But: for each img that’s a +1 request on the db >>> = + 40 requests.

Any other alternative ?


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#7 2011-02-14 15:44:42

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Get an image type


Code is topiary

Offline

#8 2011-02-14 15:54:27

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

Re: Get an image type

hablablow wrote:

<txp:smd_gallery limit="1">{ext}</txp:smd_gallery> But: for each img that’s a +1 request on the db

Depends how you’re creating your gallery in the first place. If you create it with smd_gallery instead of using the built-in tags then tacking on the extension as part of your form, the number of requests should = the number of images in the gallery. Ummm, I think. Can you supply your code so we can see if it can be optimised? As you say, it may be possible to use a line of PHP, but it depends how you’re getting the images in the first place.

Last edited by Bloke (2011-02-14 15:55:31)


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

#9 2011-02-14 19:49:37

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: Get an image type

Alright folks thank you for your proposals, but since I’m using Mary’s plugin upm_image, I thought the easiest way to go was to modify it. So I created a custom tag to retrieve image extension: <txp:upm_img_ext />

All you have to do is add these line in Mary’s code:

Around line 37:

'ext'					=> '',

Around line 355:

'ext'					=> '',

Around line 504:

'ext'					 => $row['ext'],

And finally around line 715, create the tag by adding:

	function upm_img_ext($atts = array())
	{
		global $upm_img_custom;
		upm_img_custom_assert();
		return $upm_img_custom['ext'];
	}

And for my concerns about the number of requests it does on the db = none.

Et voilà !

Last edited by hablablow (2011-02-14 19:55:03)


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

Board footer

Powered by FluxBB