Resizing images within a view

shortexxx's picture

Hi all, I'm fairly new to drupal 6 and had a slight query which I'm hoping somebody can help me with.

I have created a view called "News" and wish to display most recent news(obv). I have enabled the CCK for users to upload images when creating a new news article. The problem being that when user upload images to news articles, they will uploaded in various sizes.

In the view I have created called "News", I wish to use the "Rewrite the output of this field" option to resize the image automatically but this seems to be a big problem as I'm not too familiar with html or php.

So far I have the code:

img src='[field_image_fid]' width="304" height="171"

This doesn't work. Can anybody help me with what im doing wrong?




jenifer ratchanya's picture

i am new to drupal here i face a problem to include image slide show in all the pages of my site if anyone can help me

are you using views for the

shortexxx's picture

are you using views for the slideshow?

jCarousel or Views Slideshow

cithukyaw's picture

These modules may be helpful :

jCarousel :
Views Slideshow :

With Regards,

Thank you, these modules also

shortexxx's picture

Thank you, these modules also helped alot!

God Bless!


thecodecutter's picture

@shortexxx Take a look at imagecache. It enables you to setup presets for your images.
here's a link -

Thanks! Imagecache done the

shortexxx's picture

Thanks! Imagecache done the job!

God Bless!

Imagecache, Filefield, Views Slideshow

esod's picture

For resizing images within a view:

You'll want to resize your images using an ImageCache preset. First, install and enable these modules:

  • Advanced Help
  • CCK (Content)
  • FileField
  • ImageField
  • ImageAPI
  • ImageAPI GD2
  • ImageCache
  • ImageCache UI
  • Views
  • Views UI

Then create a new ImageCache preset by going to admin/build/imagecache/add. If you use the Add Scale Action, you can, for instance, set the Width of uploaded images at a fixed amount and leave the Height blank, so all the images will appear with the same width but different heights. Or vice-versa. In any case, create the ImageCache preset that satisfies your requirement, and then it's off to the View.

I'll assume the CCK image field is called image. In the view called "News", in the field Content: Image, choose your new image preset from the options under Format:. After saving the view, the uploaded images will appear uniformly.

IMO, "Rewrite the output of this field" is not the right direction to go in.

You may want to have a look at:

I find the tutorials uniformly instructive.

For a Views Slideshow:

Install and enable all of the above modules, plus:

  • Views Slideshow
  • Views Slideshow: SingleFrame

There is an excellent tutorial for creating a Views Slideshow here:

Thanks alot Esod. Imagecache

shortexxx's picture

Thanks alot Esod. Imagecache done the trick, your help is much appreciated! Do you happen to know how the same resizing can be applied to videos (e.g. Youtube videos?)

God Bless!

how can i split a word

jenifer ratchanya's picture

how can i split a word and check the letters individual in javascript or php script

No sweat. Glad things are working out.

esod's picture

For videos (YouTube videos in this example), try these instructions.

Install and enable the following modules:
* Content
* Embedded Media Field
* Embedded Video Field
* Media: YouTube

Add Content Type
Name: Video
Type: video
Description: A content type for YouTube Videos
Submission form settings
Title field label: Title
Body field label: (leave blank and there is no body field)
Save content type

Manage Fields
New field
Label: Video
Field name: video
Select a field type: Embedded Video
Select a widget: 3rd Party Video

Video Display Settings:
320 w
240 h

Video Preview Settings:
320 w
240 h

120 w
90 h

Save field settings

Title: Tour the Georgia Aquarium

Title: Kuroshio Sea

View name: Video
View description: A view of videos
View type: Node

Node: Published: Yes
Node: Type: is one of: Video

Content: Video (field_video)
Embedded Video - Appears in Video

Basic settings:
Style: Grid

Add display - Page
Page settings
Path: video
Menu: Normal menu entry
Title: Video

go to /video and view your handiwork.

Additionally, there are numerous resizing options in the View under Fields - Content: Video - Format:. More fields with different size settings can be created in the Video content type as well.

Help with resizing image

holeepassion's picture

Ok, I have created a new content type with image as one of the field , say upload_image. How to get the image to be scaled down to fit the page as I uploaded full resolution photos so that I do not have to edit the files before hand ?

Thank you

Great! Using CCK filefield for the upload_image field

esod's picture

Great! If you've used CCK for the field upload_image, you're well on your way. If you've used Upload for the field upload_image, you'll need to go back and use CCK.

Hopefully if you follow my previous post in this discussion (see "Imagecache, Filefield, Views Slideshow") you will be able scale down the image using Imagecache alone. I'm assuming your use case doesn't permit using an image editor for the image scaling.

With full resolution photos, there is a chance you will exceed the Maximum file size in PHP. If that occurs, you will need to adjust the post_max_size in php.ini, but otherwise, you should be fine, assuming your server has the storage capacity for the long term, depending on site traffic.


holeepassion's picture

i did used CCK, am not sure how to upload a full image but only display smaller image on the node itself.

I did use viewslideshow but on the node itself, i want to show smaller image too, is that possible ?


Smaller images are possible

esod's picture

These links will help:

To upload a full image but only display a smaller image on the node itself, you'll probably want to adjust the field display at admin/content/node-type/YOURCONTENTTYPE/display, which will list imagecache presets.

To show a smaller image on a views slideshow, look for the option in the View.

Thanks heaps

holeepassion's picture

That sorts that issue out :D

Since you know so much, could I ask another question here. I did some crawling on my website to generate sitemap.xml. Now, I see that it shows for example. I am wondering isn't it that a security issue. How could it lead to that page when it should be based on user or module permissions ? have I done something wrong here ? How to block the access to that area, only allowing via user permissions ? Possible ?

otherwise, setting restrictions on files become useless than ?

I did create using CCk and then on the site link, it comes to .. why can't the crawler go to this link instead for photo ?

Thanks in advance

That's a good question

esod's picture

That's a good question. I'd like to hear what other have to say about it.

My guess is some things on the internet are public and some things are private. For example, log in to your bank, right click on a picture and choose View Background Image. You'll see the picture in the browser and a path in the URL Bar. I can only assume that's not a security issue.

Anyway, why not start a new discussion? Hopefully others with greater expertise will chime in. Since this discussion is about Views and Slideshows, your question about security might not get noticed.


Thanks esod!

goldengalaxy's picture

This works gr8.. Thanks a lot..

pls reply me as soon as

jenifer ratchanya's picture

pls reply me as soon as possible

This is from hari, install

hariharasuthan_mk's picture

This is from hari,

install image cache and create preset like width="304" height="171" assume preset name is => my_preset

using the below code

print theme('imagecache', ‘my_preset’, $my_variable, $alt, $title, $attributes);


Drupal Dojo

Group organizers

Group events

Add to calendar

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: