18.10.2016 Views

Drupal 7 Module Development

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Working with Files<br />

and Images<br />

<strong>Drupal</strong> 7 introduced a new API for files and images, bringing the functionality of<br />

popular contributed modules like Imagecache and Imagefield into core for the<br />

first time. In this chapter, we will build two modules that take advantage of this<br />

new functionality. Some of the concepts we will cover are:<br />

• Understanding <strong>Drupal</strong>'s public and private filesystems<br />

• Associating files and images with content<br />

• Implementing a stream wrapper for custom file handling<br />

• Programmatically manipulating images using image styles and effects<br />

• Understanding <strong>Drupal</strong>'s new Image Styles functionality<br />

• Implementing your own image effects for use with Image Styles<br />

By the time you are done with this chapter, you should have a good understanding<br />

of how to manipulate files and images using <strong>Drupal</strong>, including some methods for<br />

retrieving remote files and images.<br />

The Twitpic and watermark modules<br />

In this chapter, we will be building the Twitpic module. This module will enable<br />

you to interact with images stored on the Twitpic website (http://twitpic.<br />

com) and integrate them with <strong>Drupal</strong> in a variety of ways. It provides a stream<br />

wrapper that allows developers to pull images from Twitpic by referring to them<br />

with a custom URI, and offers a demo of how <strong>Drupal</strong>'s Image API can be used to<br />

manipulate these images.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!