18.10.2016 Views

Drupal 7 Module Development

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Working with Files and Images<br />

Default styles are very simple to implement, but as you can see they bring along<br />

with them an enormous amount of functionality that can dramatically improve<br />

your workflow. If you spend a lot of time configuring image settings or moving<br />

configuration between sites, there is really no reason not to implement your styles<br />

in a module using hook_image_default_styles().<br />

Summary<br />

The new File and Image APIs in <strong>Drupal</strong> 7 not only make management and<br />

maintenance of these assets much easier, they are also great fun to play around<br />

with and amazingly easy to use. By now you should be comfortable with the central<br />

concepts of file management in <strong>Drupal</strong>. You should know the difference between<br />

<strong>Drupal</strong>'s public and private file systems, and understand how <strong>Drupal</strong> associates file<br />

metadata with the files they represent in the files table. You should also have a<br />

good understanding of stream wrappers and how they are implemented in <strong>Drupal</strong><br />

7. Finally you should know how to use the Image API to crop or otherwise modify<br />

images, and how to save these modifications as Image Styles for use in your content.<br />

Many of the examples in this chapter are just shells, and could easily be improved<br />

upon or expanded. For instance, it would be reasonably easy to expand the<br />

watermark module so that it can position the watermark based on user choice, or<br />

outline it for easier readability against different backgrounds. Experimentation<br />

is encouraged!<br />

Earlier we discussed how pre-defined image style settings can improve workflow<br />

and maintainability. In the next chapter we kick that concept up a notch by learning<br />

how to create completely pre-configured <strong>Drupal</strong> installations using install profiles.<br />

[ 342 ]

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

Saved successfully!

Ooh no, something went wrong!