<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-58XD3MJ" height="0" width="0" style="display:none;visibility:hidden">

Drupal DIY Tip: Exporting ImageCache Presets

Design & Development

For most Drupal configurations, it is advisable to use exporting functionality. In addition to facilitating version control and code duplication, this method offers more direct control over the node's settings, fields, etc. Recently I tried to export the code of an ImageCache preset, but found little guidance online as to where to insert the extracted code. With the assistance of Michelle Lauer (and by assistance I mean step-by-step instruction), I crafted the following simple procedure. Hopefully this will help the next person through the process!

  1. Go to the ImageCache page (usually site/admin/build/ImageCache), find the desired preset on the list, and click the accompanying Export link.
  2. Before copying your code, navigate to the pertinent module (usually a custom module just for your site).
  3. If the function "MYMODULE_imagecache_default_presets()" doesn't exist, create it now, and insert the line "return $presets;" before the function's closing bracket. If the function already does exist, take note of whether other presets exist.
  4. Return to the page containing the exported code. If there were pre-existing presets, then copy all but the first line ("$presets = array();"), and paste after that same line in the hook. Otherwise, copy everything and paste into the hook before the return statement. Save the file.
  5. Return to the ImageCache list, then refresh, or even flush all caches if you feel so inclined. The same preset should appear in the list, but with the word "Revert" substituted for "Delete". You may now click that button and confirm. In doing so, you remove the database copy of the preset and leave Drupal to work with only the exported code version.
  6. Congratulate yourself, because you're done.

by Zach Silversmith, CommonPlaces e-Solutions The award-winning engineering team at CommonPlaces thrives on Drupal solutions and streamlining the CMS development process. Need help getting your Drupal site to the next level? Talk to us today about our CP Mentor program or CP Rescue services -- and get your site launched!

Leave Your Comment

Want More Digital Insights Delivered to Your Inbox?

Copyright © 2020 CommonPlaces, Inc. | Privacy Policy | Acceptable Use Policy