Theming views to use imagecache

By Benjamin Melançon
on 25 Sep
0 comments

Key words and phrases

views, imagecache, and theming view templates

Tags

Description

Agaric needs to make a view, such as a preview of an image gallery for the front page of a site, use imagecache to generate cropped and resized thumbnails.

Resolution

<?php
print_r
($node);
?>
stdClass Object
(
[nid] => 6
[files_filepath] => sites/anjaliforberpratt.com/files/images/137901886019f.jpg
)

So it's saying, I am an object, I am called node, this is what I am made up of.

We want it to print our node, the entire node.

So we have to load it:

$agaric_image_node = node_load()

Here we've found the piece we care about:

[images] => Array (
[_original] => sites/anjaliforberpratt.com/files/images/137901886019f.jpg
[preview] => sites/anjaliforberpratt.com/files/images/137901886019f.preview.jpg
[thumbnail] => sites/anjaliforberpratt.com/files/images/137901886019f.thumbnail.jpg
)

This is in a node object, so when we call it it will be in the form $agaric_image_node->images['_original'].

And this is the most inefficient way to theme an image to use an imagecache preset through views that I can imagine.

If there isn't a view that can output the filepath of the original image, we should make a module that does that.

 

Post new comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <small> <pre> <strike> <sub> <sup> <kbd> <s>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.