Hello,

is there a way to use this module together with views?

I have a situation like this:

In a cck Link field i save a url to an external image.
with Views i want to show this image, embeded in a link ( via rewrite output) and the image should be resized by imagecache.

I could not find a way to do this using the 2.0 Version of this module.

Am I overseeing something, or is the support for views missing?

Comments

larowlan’s picture

Status: Active » Fixed

You can
a) create a new formatter for the url field (either in code or using custom formatters module).
b) you can use views custom field project to create php based fields.
LR

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jaydxb’s picture

Hello,
Thanks for this module.
This is what exactly I am looking for. However, I am not able to utilise it still.
I am using views, D6. Would like to rewrite the field [field_img_data_value], which contains an external url, to show the image.
Installed Views Custom Field to render php.

Where do I use

$image_url = imagecache_external_generate_path($url, $preset);

and Only local images are allowed. print $image_url;" alt="image description" />

I can't see a folder (external) created under the site>files

In the above code, where is $url, $preset defined?
Thanks for any help.
Jay

drshearer’s picture

I came up with a solution that works with the D7 version of this module. You'll also need the Views PHP module (http://drupal.org/project/views_php) to create a global PHP field in your view. In the Output Code section of that field, add the following code:

  print theme('imagecache_external', array('path' => $data->field_field_image_embed[0]['raw']['value'], 'style_name'=> 'thumbnail'));

In this case, I'm using a text field for my external image URL with field name 'field_image_embed'. My desired imagecache preset is this case is called 'thumbnail'. Change these values to your own field name and imagecache preset, and voilà - your view should display an imagecache version of the external image.

I have not tried this in D6, but I imagine the same idea could work, using the Views Custom Field module (http://drupal.org/project/views_customfield) and the D6 version of the implementation code for Imagecache External.

stevenmhouse’s picture

While the above will work, what I'd suggest instead is using a template file in your theme's template folder for the view field. My file name is: views-view-field--field-description.tpl. You need to go to views - theme (or similar) and look for the field that you want to use external imagecache on, and click on that to get the template (only print $output). After you create and save the file in the right place, click on Rescan button in views to have it locate that file (the file name will become bold).

The advantages for sites w/ traffic: views_php stores php in the DB. This means a db request happens, then processing of the php, which takes longer. If done this suggested way, there isn't the overhead associated with the db load.

Here's my code, with the origonal line commented out.


print theme('imagecache_external', array('path' => $output, 'style_name'=> 'coupon_image_description'));

//print $output; 

jonmcl’s picture

I submitted a patch that adds a field formatter. This might solve this issue without having to use custom PHP.

#1910160: Add Imagecache External Image field formatter