Using ImageCache and ImageCrop for my Portfolio
28th April 2010
Whilst working on my own portfolio/testimonial website, I decided to have a portfolio page displaying the name of each site and a thumbnail image. For this Blog post, I'll be using a site called Popcorn Strips which I built for a friend earlier this year as an example.
I created a content type called 'Project' with a CCK ImageField called 'Screenshot'. I created a project called Popcorn Strips, used the ScreenGrab add-on for Mozilla Firefox to take a screenshot of the website, and uploaded it to the project node.
I created a View to display the published projects, and an ImageCache preset to create the thumbnail image by scaling and cropping the image to a size of 200x100 pixels.
Although, this automatically focused the crop on the centre of the image, whereas I wanted to crop from the top and left of the image - showing the site's logo and header.
I installed the ImageCrop module, which add a jQuery crop function to the standard ImageCache presents. I removed the original Scale and Crop action and replaced it with a Scale action with a width of 200px.
- Width: 200px
- Height: 100px
- xoffset: Left
- yoffset: Top
Questions? Comments? I’m @opdavies on Twitter.
About the Author
Oliver Davies is a Web Developer, System Administrator and Drupal specialist based in the UK. He is a Senior Developer at Microserve and also provides freelance consultancy services for Drupal, Symfony and Laravel applications and Linux servers.