Attaching images to nodes

This was achieved by enabling filefield and imagefield, as part of cck. I added in content type “news” a new field as shown in this capture:

ImageField is completely dependent on FileField for its data handling. This means that ImageField is now purely a “widget” for CCK, not a “field” any more, as it was in previous versions of this module.

The idea was to allow the user to upload an image, then drupal automatically:

-resizes the original image to thumbnail, to display in the node teaser.

-resizes the original image to slightly larger size than a thumbnail in the full node display page, and a javascript library (highslide, lightbox or the likes) allows to elegantly display the image at full size when user clicks on the image.

The user doesn´t have to worry about manually resizing file resolution. So, imagefield module adds the image to the news content type, ImageCache module creates the resizing/cropping presets, and Lightbox2 module displays the image at full size. The 3 modules work very well with each other. Enabling the ImageAPI GD2 module that comes in the imagecache installation is crucial, as otherwise imagecache causes drupal to output the wrong path to the thumbnails (*). The 5 modules that come with imagecache module download need to be activated. I also activated the lightbox2 module.

I created 2 presets in admin>site building>imagecache, “thumbpreset” for resizing to thumbnail and “thumbfornewsnode” for resizing to slightly larger than thumbnail. From admin>content types>news>display fields tab, settings for the output of the custom created image field can be adjusted: “thumbpreset” for the node teaser, and “lightbox2: thumbfornewsnode>original” for full node. I then adjusted from admin>site building>views to output a thumbnail in the news content type teaser page. CSS did the rest, by applying padding and a grey border to the thumbnail, to achieve the photography frame effect:

border:1px solid #CCC;

And the following style to make the “thumbfornewsnode” float to the right, when displayed at full node:

One last thing to remember is that each user role that wishes to view the images generated by a particular preset must be given permission on the admin/user/permissions page.

The following link provided help:

*: as reported in the list of bugs in:


Posted on March 18, 2010, in Uncategorized. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: