Restored guide

Displaying Image Preview Delete Node Confirmation Page

Archived 2008–2011 · 2 min read · Eric London's Drupal Blog

This restored note walks through a practical way to handle the subject below on the Drupal 6 generation of sites this blog was written for. The note is titled “Displaying Image Preview Delete Node Confirmation Page” and is written for Drupal 6.x unless a line below says otherwise.

What you are solving

Image work in this era means ImageCache presets, ImageField, and a derivative that is generated on demand. Generate heavy presets from Drush or a queue so a single anonymous page view does not exhaust the PHP memory limit. The moving parts in the historical title are: displaying, image, preview, delete, node, confirmation, page.

APIs and modules in play

  • Views arguments, filters, and theme suggestions

A practical approach

  1. Step 1. Name the outcome in one sentence: Displaying Image Preview Delete Node Confirmation Page.
  2. Step 2. Reproduce it on a development copy with the same modules enabled.
  3. Step 3. Keep the change in a custom module or in the theme, and leave contributed code untouched.
  4. Step 4. Define the preset (scale, crop, or scale-and-crop) before you write code that assumes a derivative path.
  5. Step 5. Flush only the presets you changed, and generate them from CLI when the source images are large.

Example

The sample is illustrative. Rename the function, swap in your machine names, and run it on a development copy.

// Displaying Image Preview Delete Node Confirmation Page
function notes_displaying_image_preview_delete_node_confirmatio_preset_url($filepath, $preset = 'thumbnail') {
  $preset = check_plain($preset);
  return file_create_url('imagecache/' . $preset . '/' . $filepath);
}

Check before you deploy

  • Confirm the change on a database copy, then again with the theme registry and page cache cleared.
  • Watch the PHP error log and the watchdog table for the first real request.
  • If the change alters markup, recheck the path with a keyboard and without JavaScript.

Restored guide. The original post was published by Eric London on this domain. This text is a new explanation of that subject, not a reproduction of the archived wording.