Jump to content

Recommended Posts

Posted

I have installed the thumbnail cropping tool, edited my existing "images" field so it uses the fieldtype "CropImage"

My crop setups are the default:

thumbnail,100,100

This is working fine i can create cropped thumbnails,

I just need some pointers on how use it on my template where I want to display the cropped thumbnail...

This is the template code:

<?php
/**
* Home template
*
*/
include("./head.inc");
echo $page->body;
echo "<ul id='portfolio_list'>";
$items = $pages->get('/portfolio/')->children("limit=6"); // Here we take children of portfolio page (limit=6)
foreach($items as $item) { //Loop through them
	    $image = $item->images->first();
  $thumb = $image->size(100,100);
	    echo "<li><a href='{$item->url}'><img src='{$thumb->url}' alt='{$thumb->description}'>";
	    echo "<br />{$item->title}<br />{$thumb->description}</a></li>";
}
echo "</ul>";
include("./foot.inc");

Thanks

Alex

Posted

From the thumbnails module thread:

<?php
$page->image->getThumb('thumbnail'); // single image field
$page->images->first()->getThumb('thumbnail'); // multiple images
Posted

If you use Thumbnails module, then you don't do the resizing on the template file. So no size() method if you use thumbnails.

In your template code I would change this:

$image = $item->images->first();

To this:

$thumb = $item->images->first();

Then I would remove the next line (where you use size() method).

Rest of the code you can keep, but change {$thumb->url} with $thumb->getThumb('thumbnail'). I'm not sure, but you might need to write it like this:

echo "<img src='". $thumb->getThumb('thumbnail') ."' />
  • Like 1
Posted

I can't see the thumbnail crop feature when I upload images, it was working fine previously.

The only thing I can think of is that I upgraded to processwire 2.2?

Posted

I just read the latest post in the Modules/Plugins section

about thumbnails not working in 2.2

so no need to answer my post above.

Posted

Yep, fix is coming soon. Pete already send me a pull request, but he wanted to tweak that little bit before I pull it in.

Posted

I just merged Pete's pull request, so if you grab latest version of Thumbnails then it should work. I haven't tested this yet myself, but I will soon too. Special thanks to Pete for working on this and adding great new feature (template specific crops).

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...