Alex Posted January 18, 2012 Share Posted January 18, 2012 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 Link to comment Share on other sites More sharing options...
Soma Posted January 18, 2012 Share Posted January 18, 2012 From the thumbnails module thread: <?php $page->image->getThumb('thumbnail'); // single image field $page->images->first()->getThumb('thumbnail'); // multiple images Link to comment Share on other sites More sharing options...
apeisa Posted January 18, 2012 Share Posted January 18, 2012 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') ."' /> 1 Link to comment Share on other sites More sharing options...
Alex Posted January 18, 2012 Author Share Posted January 18, 2012 Yes that worked straight away, thanks alot for explaining. Alex Link to comment Share on other sites More sharing options...
Alex Posted January 25, 2012 Author Share Posted January 25, 2012 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? Link to comment Share on other sites More sharing options...
Alex Posted January 25, 2012 Author Share Posted January 25, 2012 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. Link to comment Share on other sites More sharing options...
apeisa Posted January 25, 2012 Share Posted January 25, 2012 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. Link to comment Share on other sites More sharing options...
apeisa Posted January 25, 2012 Share Posted January 25, 2012 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). Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now