Hello,

I am building a mobile theme for my site and wish to use Image Resize Filter to change the size of embedded images to suit small mobile screens. However, I still wish the standard theme for the site to deliver the original sized images. To allow this I have written the attached patch which adds a function I have called theme_image_resize_filter_scale_factor(). This allows the theme to return a scale factor (such as "0.5") and thus have embedded images delivered at, say, half size.

It would be very helpful if this, or an equivalent, could be incorporated in the released version of the module.

With thanks, Tony

(P.S. I have created the patch under Windows with the Gnu utilities, so I apologise if it is not quite in the format required. I hope this is OK.)

CommentFileSizeAuthor
resize-patch.txt2.37 KBAnonymous (not verified)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

Returning a number in a theme function is rather abusive of the theme system. The theme system is supposed to return markup, not modify functionality or be used for configuration like this.

In the past I'd considered adding a module hook to allow something similar to what you've done here (essentially allowing the array of $images to be altered before they were resized), but after some consideration I decided that wasn't really something I was interested in pursuing. I might look into it again, but I'm leery of what sort of repercussions those changes might have.

Anonymous’s picture

I must admit I spent a long time trying to understand the difference between theme functions and module hooks, so there may well be a better way of achieving what I am trying to do. I am not sure what it would be however.

I can see that you would not want to put a full-blown theme dependent configuration option into the Filter module. If there were a module hook, I would then have to write a module which was in effect a part of, or agent of, my theme, which does not seem right either.

Can you advise a "clean" way to do what I want?

With thanks, Tony