Download & Extend

Hyphens in style names cause paths that point to non-existent derivative images

Project:Drupal core
Version:7.x-dev
Component:image.module
Category:bug report
Priority:normal
Assigned:CrookedNumber
Status:closed (fixed)

Issue Summary

Try placing a hyphen in your image style name. Images created by that image style have a mangled path and won't display.

It looks like the culprit is the preg_match() in image_field_formatter_view()

<?php
 
if (preg_match('/__([a-z0-9_]+)/', $display['type'], $matches)) {
   
$image_style = $matches[1];
  }
?>

which (if the $display['type'] has a hyphen in it) will created a truncated $image_style and (eventually) an incorrect image path.

E.g.,

You have an image style name of "example-with-hyphen". But the initial path created is /image/generate/example/public/IMAGE_NAME.jpg, which will send back a 404.

I'm assuming that the actual bug is in preg_match() [vs. simply not allowing hyphens in names, to begin with].

Comments

#1

AttachmentSizeStatusTest resultOperations
image-hyphens_in_style_names_fail-818686-1.patch680 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 20,584 pass(es).View details

#2

Status:active» patch (to be ported)

#3

Status:patch (to be ported)» needs review

#4

looks fine can someone test this code?

#5

This could be tested after #606598: Human readable image-style names

#6

Status:needs review» reviewed & tested by the community

confirmed bug.
verified patch #1 fixes it.

#7

Status:reviewed & tested by the community» fixed

Committed to CVS HEAD.

#8

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here