Skip directly to content

Image Field: change image styles dynamically and manipulate the link to the original image (D7)

on Tue, 09/20/2011 - 15:04

Today I had a problem with some image fields. For my purpose I was manipulating the image style that should be displayed dynamically, and I guess that this odd use was causing for the field to disrespect the setting I had in my view mode for it not to link to the original image. So after a llittle playing around I figure out how to manipulate the image field's renderable array to keep it from displaying as a link to the original image (or to force the linking if you would like).

The renderable array for the field looks like this.

The important part is the key of 0. This is the only image in

How Do I Theme my Entity?: Leverage Entity API's Theme Suggestions

on Wed, 10/26/2011 - 01:26

The entity API offer us a few theme suggestions that we can use to override how our entities look.

Let's say that you entity type is called "post" and one of your bundles is called "blog", and that you have created an entity with id 1. The following theme suggestions are available:

post.tpl.php
post__blog.tpl.php
post__blog__teaser.tpl.php (teaser is a view mode)
post__1.tpl.php

This offered you a very fine grain level of customization to theme things according to your needs.

To use these tpl.php files we need to let drupal know through the theme hook.