Extra Image Plugin: Proper Crop?

Discuss PivotX 2.0.x extensions here, and view extensions that are available for download.

Extra Image Plugin: Proper Crop?

Postby xzjia » Thu Oct 08, 2009 2:05 pm

Right now I am passing a "width" variable into the [[ image ]] tag for the extra image:

Code: Select all
[[ image file=$entry.extrafields.image alt=$entry.extrafields.description width=260 ]]


I tried to pass a height variable as well but it distorts the images, so I'm resorting to using a container DIV and overflow the excess height, while leaving shorter images with extra backgrounds showing.

What I want is the behavoiur from the gallery script:

Code: Select all
<img src="%pivotxurl%includes/timthumb.php?src=%filename%&amp;w=180&h=150&zc=1" alt="%filename%" />


Where passing the width and height does a "proper" crop of the image.

Can it be done?
xzjia
 
Posts: 110
Joined: Tue Dec 11, 2007 6:26 pm

Re: Extra Image Plugin: Proper Crop?

Postby hansfn » Thu Oct 08, 2009 6:34 pm

Doesn't

Code: Select all
<img src="[[pivotx_dir]]includes/timthumb.php?src=[[$entry.extrafields.image]]&amp;w=180&h=150&zc=1"
    alt="[[$entry.extrafields.description]]" />

work?

(Corrected code as suggested below.)
hansfn
Developer
 
Posts: 3282
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: Extra Image Plugin: Proper Crop?

Postby xzjia » Thu Oct 08, 2009 7:24 pm

Aha, Perfect!

It works if I enclose the $entry.extrafields.image and $entry.extrafields/description with smarty tags [[ ]].

I tried to do this:

Code: Select all
[[ image file="%pivotxurl%includes/timthumb.php?src=%entry.extrafields.image%&amp;w=180&h=150&zc=1" alt=$entry.extrafields.description width=260 ]]


Stupid me not trying to abandon the [[ image ]] tag completely and just use plain old <image> tag.

Also notice the vain attempt to convert variable into the %xxx% equivalent: %entry.extrafields.image%.

This is my major gripe about the current doc, too many tags are shown only in 1 form ($xxx or %xxx%) but not both when both are available and are needed in different contexts. Really would be nice to have a chart showing both $xxx variable and %xxx% variables, but that's another issue.



Btw. Are those cropped images (and for the gallery thumbnails as well) cached?
xzjia
 
Posts: 110
Joined: Tue Dec 11, 2007 6:26 pm

Re: Extra Image Plugin: Proper Crop?

Postby hansfn » Sat Oct 10, 2009 6:16 am

Yes, timthumb.php caches the generated images (in the db/cache/thumbnails/ directory).
hansfn
Developer
 
Posts: 3282
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway


Return to 2.x Extensions

Who is online

Users browsing this forum: No registered users and 9 guests

cron