theme

Views template override function for a field to pad top of an image to center it

This method is dependent on running the images through an image style to ensure that the width and height tags are added to the img tag, and that the height of the area to be centered is known. This is pretty easy for fixed sized areas fitting images, like in a list or gallery.

Instead of making a views-view-field--featured--field-image-cache-fid.tpl.php file, this function produced the output instead. In this example, I know that the height of the div is of a fixed 155px in height.

Views theme template functions instead of template files

Normally when overriding a views template it's a case of create a file like views-view-unformatted--featured.tpl.php. But this is actually a performance hit when it could be picked up as a theme template function instead.

The above function would be

Theme images in Drupal 7 - The new imagecache is image styles

ImageCache was the Drupal 6 way of doing things when you wanted a modified version of an already existing image on the site. Instead of manually manipulating the image and keeping a copy of it manually, you could setup an ImageCache preset which would be used to manipulate the image automatically.

In Drupal 7, this functionality is now in the core and it has also gone through some subtle changes to keep up with changes in the core.

Subscribe to RSS - theme