If there is a float value in the style on the image, it is ignored when using the "If resized, add a link to the original image" option. Since the float style is on the image inside of the a tag, and the a tag is (typically) inline and not floated, the image is displayed inline.

Since the height and width are parsed from the img tag for resizing, I would like to also parse the float value from the style attribute, and apply that to the link tag that's added in.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

BrockBoland’s picture

Status: Active » Needs review

The attached patch will look for a float in the style on the image, or an align attribute, and if found, add it as a float on the link that's wrapped around the image.

This needs:

  • Usability review. Will users expect this float to be added? Should there be a checkbox on the filter config to enable/disable it?
  • More testing. I've been testing it out with some test nodes, but it could use more testing under more conditions.

And one important caveat:

  • This will not work under the typical Filtered HTML format. If the "Limit allowed HTML tags" filter is on, the style attribute (which includes the float) will be stripped from the link tag. There's really not a good way around this.

The caveat might negate any desire for an enable/disable checkbox: it won't work as most users will expect, so it's probably only useful in cases where users will not be restricted to Filtered HTML.

BrockBoland’s picture

And, of course, the patch file.

BrockBoland’s picture

Slight change from my last patch. As I mentioned in that comment, the important caveat was that the style attribute—and the float value in it—is stripped when using the standard Filtered HTML text format. The change here is to add a class to the link (floatleft or floatright) so that these classes can be defined in the site CSS.