Hi, I sort of rolled together http://drupal.org/node/59209 and http://drupal.org/node/70099 into a single patch. Besides adding the "none" alignment I also add a "center" alignment. I think it's not quite perfect but it's a good first stab. Besides the attached patch you will need to add the following rule to wherever you keep your style sheet:

span.center {
  margin: 0 auto;
  display: block;
}

Span's not a block level element unless you make it one, so it can't have a specified size, so you can't center it with automatic margins. Hence, we make it a block, and give it automatic left and right margins. This is not a floating block so content after it does not have to clear it.

I rolled these patches together because centering alignment involves working with the image size.

I decided to move the addition of the original size inside the check that the program uses to determine if you're allowed to use arbitrary sizes. This should ideally be a separate option but I haven't gotten there yet (and may not, since it doesn't really apply here.)

Comments

hyperlogos’s picture

StatusFileSize
new3.21 KB

I changed my mind and added a permission called 'use original size', and moved the code to insert the original size option so that it now requires this permission. (I think as it's written you might have to have "Access advanced options" as well, not sure. Not sure if this is desirable or not, either.) This is the only change between the patches, so whichever behavior the community would like is available and fine with me :)

hyperlogos’s picture

Patch updated for CVS version (cvs, 23/10/2006 - 22:46)... somewhere along the line apparently something changed because the original size option used to work, and now it doesn't. Now, it works again. I'm now using only API calls to get the information; these calls use the installed image toolkit, whee.

This patch rolls together the original size and alignment patches (both "none" and "center") into a single patch.

hyperlogos’s picture

Patch updated for CVS version (cvs, 23/10/2006 - 22:46)... somewhere along the line apparently something changed because the original size option used to work, and now it doesn't. Now, it works again. I'm now using only API calls to get the information; these calls use the installed image toolkit, whee.

This patch rolls together the original size and alignment patches (both "none" and "center") into a single patch.

hyperlogos’s picture

Version: 4.7.x-1.x-dev » 6.x-3.x-dev
StatusFileSize
new4.57 KB

Changing version to cvs, and I eliminated a needless variable so I'm resubmitting.

RobRoy’s picture

Status: Needs review » Needs work

@drinkypoo could you submit a unified diff patch described under http://drupal.org/diffandpatch? I'll take a look once that is up. Thanks.

hyperlogos’s picture

StatusFileSize
new4.06 KB

Here 'tis. I ended up patching the .css file in the bargain, might as well. (so this is a recursive unified diff, whee.)

onionweb’s picture

I find the centering does not work.

However. if instead of

+  if ( $attributes['align'] == "center" ) {
+    $output = "<span class=\"inline {$attributes['align']}\" style=\"width: {$attributes['width']}px;\">";
+  } else {
+    $output  = "<span class=\"inline {$attributes['align']}\">";
+  }

You leave that bit the way it was, and add "text-align:center" to the span.center class, plus

change


 $output .= "<span class=\"caption\" style=\"width: {$width}px;\">$caption</span>";

to

    if($attributes['align']=='center'){
    $output .= "<span class=\"caption\">$caption</span>";
    }else{
    $output .= "<span class=\"caption\" style=\"width: {$width}px;\">$caption</span>";
    }

everything works.

hyperlogos’s picture

text-align: center; is not supposed to center anything but text. It was originally implemented to behave this way in IE (official suicide bomber of the ACID2 test) because CSS centering is hard. If Moz does it now it's only to try to achieve parity with IE, but it's still not compliant CSS.

It works properly here; maybe we just need a different name for the style to avoid a collision? Is there a standard drupal style for centering? I'll set up a new test site and test out the patch on a plain vanilla install to see if it works there.

darren oh’s picture

Version: 6.x-3.x-dev » 4.7.x-1.x-dev

I would appreciate a patch for the latest 4.7 version. Marked 70099 and 60771 as duplicates of this issue.

hyperlogos’s picture

StatusFileSize
new4.16 KB

Here is the patch for img_assist-4.7.x-1.x-dev.tar.gz, which I retrieved about five minutes ago.

darren oh’s picture

Status: Needs work » Fixed

Fixed in CVS commit 46560.

hyperlogos’s picture

Thank you! You might amend your cvs message to note that it's also alignment options (provides none and center.)

darren oh’s picture

Sorry, I don't know how to amend a CVS message.

Anonymous’s picture

Status: Fixed » Closed (fixed)