Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
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__
Offline
Offline
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__
Offline
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.
Offline
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__
Offline
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__
Offline
Offline
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
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__
Offline
Pages: 1