开发者

Can I get imagefield to NOT create thumbnails?

开发者 https://www.devze.com 2023-04-12 15:40 出处:网络
I\'m working in Drupal 6.I need thumbnails for the images that are getting uploaded to my site, but, for a variety of reasons, I need several different sizes for different kinds of images.Thus I\'m in

I'm working in Drupal 6. I need thumbnails for the images that are getting uploaded to my site, but, for a variety of reasons, I need several different sizes for different kinds of images. Thus I'm in effect rolling my own thumbnails with imagecache and adding some hooks to get them inserted into the right places. The result is that I don't really need or want the thumbnails that imagefield wants to generate, and would prefer not having them clutter up my server. Is there any way to get imagefield to just not create these开发者_Go百科 thumbnails? Or would that screw up something else that I'm not thinking about? Thanks!


there aren't any ways to do this without hacking the module, which is a shame!

Try this:

When you create your own thumbnails, run the following code on the uploaded file.

file_delete(imagefield_file_admin_thumb_path($file, FALSE));

Here's the function in imagefield_file.inc (called on line 22 in imagefield_file.inc):

/**
 * Implementation of hook_file_delete().
 *
 * Delete the admin thumbnail when the original is deleted.
 */
function imagefield_file_delete($file) {
  if (imagefield_file_is_image($file)) {
    file_delete(imagefield_file_admin_thumb_path($file, FALSE));
  }
}

I can't test it at the moment I'm afraid, but it might be a starting point! It's also a bit messy, as the thumbnail will be generated, and then deleted! According to line 12 in imagefield_file.inc, the thumbnails are generated on preview...you might be able to override this somehow?

0

精彩评论

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

关注公众号