[TYPO3-content-rendering] Proposed fix for image alignment and Firefox/Mozilla

Michael Stucki michael at typo3.org
Tue Nov 8 20:48:55 CET 2005


There was no feedback on this! Please test the attached patch _now_ and give
feedback ASAP, otherwise I will not be able to add this fix to 3.8.1.

Please notice the attached patch. (Martin, I've slightly changed your patch
to make sure that $table_align does not contain an empty value if $align
was not set.)

- michael

Martin Kutschker wrote:

> Hi!
> 
> I guess that few on this list use the default css_styled_content
> implementation of image ot text w/image, but anyway  here comes a fix
> for it.
> 
> The problem is that the image alignment above or below text is broken in
> Firefox/Mozilla. The reason is that
> 
>    <div style="text-align: right"><table>...</table></div>
> 
> won't work. To make it work you have to set margins on the table
> 
>    <table style="margin-left: auto; margin-right: 0px">...<table>
> 
> For centering you need to set both margins to auto, for left alignment
> the left margin is 0 and the right auto.
> 
> Fortunatley you can mix both settings. So I have come up with a solution
> that works for me in IE 6 and Firefox.
> 
> function IMGTEXT($conf) {
>   ...
> 
>   if ($c)     {
>    // Table-tag is inserted
> 
>    // OLD CODE
>    // $i=$contentPosition;
>    // $table_align = (($i==16) ? 'align="'.$align.'"' : '');
> 
>    switch ($contentPosition) {
>     case '0': // above
>     case '8': // below
>      // these settings are needed for Firefox
>      switch ($align)  {
>       case 'left':
>        $table_align = 'margin-left: 0px; margin-right: auto';
>       break;
> 
>       case 'center':
>        $table_align = 'margin-left: auto; margin-right: auto';
>       break;
> 
>       case 'right':
>        $table_align = 'margin-left: auto; margin-right: 0px';
>     }
>     $table_align = 'style="'.$table_align.'"';
>     break;
> 
>     case '16':        // in text
>      $table_align = 'align="'.$align.'"';
>     break;
> 
>     default:
>      $table_align = '';
>   }
>   ...
> }
> 
> I'm not sure if it's needed to set the margins to 0px (if not auto). The
> default values may be enough. And without it yo still can set the a
> (default) margin with CSS.
> 
> What do you think of that solution?
> 
> Masi

-- 
Use a newsreader! Check out
http://typo3.org/community/mailing-lists/use-a-news-reader/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image_align_fix.diff
Type: text/x-diff
Size: 1571 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-project-content-rendering/attachments/20051108/38bfcaae/attachment.bin 


More information about the TYPO3-project-content-rendering mailing list