开发者

Resizing/Scaling images in a view by setting custom CSS width

Problem

I'm doing some maintenance and changes on a Drupal site, but I'm not an expert. My problem is the following. I have a view that produces an HTML table by fetching some field values and putting them into the table columns. One of these field is an image. Unfortunately each image has a different size (images are uploaded by users), and so the overall table looks ugly. I would like to resize/scale images so that they all have the same width. I know I can use CSS to set the image width to a fixed val开发者_如何学JAVAue, and let the height adjust accordingly:

<img src="..." style="width:70px"/>

Unfortunately I don't know how to make Drupal output this custom HTML when processing my view. Currently the produced HTML looks like this:

<img 
  class="imagefield imagefield-field_imgsmall" 
  width="100" 
  height="39" 
  alt="" 
  src="http://www.mysite.org/sites/default/files/foobar.png?1292948397">

and I guess this is produced by one of the view's fields (namely field_imgsmall).

First question is: what is that number after the ? in the src URL? And where does it come from? (Each image has a different number in the corresponding src URL)

What I've tried

I've noticed that in the "edit view" mode, when selecting a field, I can check the option Rewrite the output of this field, and there I can mix HTML and substitution patterns. However, I've seen that one of the substitution patterns that's available to me ([field_imgsmall_fid]) is actually producing the entire HTML above ... so I can't customize it.

What can I do? Am I going in a totally wrong direction?


You should look into the imagecache module, which allows you to resize images (and cache the results, so the resizing process rarely happens).

Here's a walkthrough:

http://2bits.com/articles/drupal-using-imagecache-with-views-and-cck-imagefields.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜