News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Allowing align in img tags

Started by Mike Bobbitt, October 30, 2004, 10:30:20 AM

Previous topic - Next topic

frost

#20
i don't know what to put where  :D

and i tried the solution from mike's post - don't work at all, plus i can't find the line mentioned there...
they're different, see:

'~\[img(\s+width=([\d]+))?(\s+height=([\d]+))?\s*\](?:<br />)*(.+?)(?:<br />)*\[/img\]~ei' => isset($disabled['img']) ? '\'$5\'' : '\'<img src="$5" alt=""\' . (\'$2\' != \'\' ? \' width="$2"\' : \'\') . (\'$4\' != \'\' ? \' height="$4"\' : \'\') . \' border="0" />\'',
'~\[img(\s+width=([\d]+))?(\s+height=([\d]+))?\s*\](?:<br />)*(.+?)(?:<br />)*\[/img\]~ie' => isset($disabled['img']) ? 'preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$5", array("@" => "&#64;")))' : '"<img src=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$5", array("@" => "&#64;", "\"" => "&quot;"))) . "\" alt=\"\"" . ("$2" != "" ? " width=\"$2\"" : "") . ("$4" != "" ? " height=\"$4\"" : "") . " border=\"0\" />"',




how would i implement [Unknown]'s solution?

Anguz

#21
In Subs.php search for

'~\[center\](.+?)\[/center\]~i' => isset($disabled['center']) ? '$1' : '<div align="center">$1</div>',


and after it add the line [Unknown] gave you for the tag

'~\[float=(right|left)\](.+?)\[/float\]~' => '<div style="float: $1;">$2</div>',


Then to the style.css file

td
{
clear: both;
}


The clear style may need a bit more work if it doesn't work right, I haven't tested this. HIH.
Cristián Lávaque http://cristianlavaque.com

frost

#22
Quote from: Anguz on September 03, 2005, 12:29:45 AM
In Subs.php search for

'~\[center\](.+?)\[/center\]~i' => isset($disabled['center']) ? '$1' : '<div align="center">$1</div>',


There is no such line in my Subs.php.

the nearest thing is:

if(isset($add['[center]'])){
$arr1[] = '~\[center\](.+?)\[/center\]~i';
$arr2[] = isset($disabled['center']) ? '$1' : '<div align="center">$1</div>';
}


Afer that i added:

if(isset($add['[float]'])){
$arr1[] = '~\[float=(right|left)\](.+?)\[/float\]~i';
$arr2[] = isset($disabled['float']) ? '$2' : '<div style="float: $1;">$2</div>',
}



I don't even need to say it don't work ;D

But then, i found this piece of code:

if(isset($add['[img]']) || isset($add['[img '])){
$arr1[] = '~\[img(\s+width=([\d]+))?(\s+height=([\d]+))?\s*\](?:<br />)*(.+?)(?:<br />)*\[/img\]~ie';
$arr2[] = isset($disabled['img']) ? 'preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$5", array("@" => "&#64;")))' : '"<img src=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$5", array("@" => "&#64;", "\"" => "&quot;"))) . "\" alt=\"\"" . ("$2" != "" ? " width=\"$2\"" : "") . ("$4" != "" ? " height=\"$4\"" : "") . " border=\"0\" />"';
}


Below it i added:

if(isset($add['[img]']) || isset($add['[img '])){
$arr1[] = '~\[img(\s+width=([\d]+))?(\s+align=(.+?))?\s*\](?:<br />)*(.+?)(?:<br />)*\[/img\]~ei';
$arr2[] = isset($disabled['img']) ? '\'$5\'' : '\'<img src="$5" alt=""\' . (\'$2\' != \'\' ? \' width="$2"\' : \'\') . (\'$4\' != \'\' ? \' align="$4"\' : \'\') . \' border="0" hspace="5"/>\'';
}


Result: a tag like this
[img align=left]imglink[/img]
works like a charm!


until the next Subs.php update, at least ;)

Anguz

QuoteI don't even need to say it don't work

At the end of the line that starts with $arr2 you should have used a ; instead of a ,. Cool that you managed to make it work with the attribute in the img tag though.  :)
Cristián Lávaque http://cristianlavaque.com

frost

yeah, well, there's a saying in Croatia:

Ako nece Muhamed brdu, onda ce brdo Muhamedu


(literally: if muhamed won't go to the hill, then the hill will come to muhamed)


;)

Anguz

There's a similar one over here, I'm glad you took the initiative. That's how I learned how to code some years ago.
Cristián Lávaque http://cristianlavaque.com

ivo2296

Quote from: Elijah Bliss on November 02, 2004, 05:31:48 AM
Try this:

In subs.php

Find:
'~\[img(\s+width=([\d]+))?(\s+height=([\d]+))?\s*\](?:<br />)*(.+?)(?:<br />)*\[/img\]~ei' => isset($disabled['img']) ? '\'$5\'' : '\'<img src="$5" alt=""\' . (\'$2\' != \'\' ? \' width="$2"\' : \'\') . (\'$4\' != \'\' ? \' height="$4"\' : \'\') . \' border="0" />\'',

Add below:
'~\[img(\s+width=([\d]+))?(\s+align=(.+?))?\s*\](?:<br />)*(.+?)(?:<br />)*\[/img\]~ei' => isset($disabled['img']) ? '\'$5\'' : '\'<img src="$5" alt=""\' . (\'$2\' != \'\' ? \' width="$2"\' : \'\') . (\'$4\' != \'\' ? \' align="$4"\' : \'\') . \' border="0" hspace="5"/>\'',


That works fine when Faster Parsecode mod is not installed. But with Faster Parsecode the forum shows blank page when i added the code.

xtremecruiser

Quote from: Mike Bobbitt on August 31, 2005, 04:54:19 PM
The new beta allows admins to use [html] tags which solves the problem for me...

I am not seeing this working in SMF 1.1 RC1 ?

Mike Bobbitt

It works, but you have to be a true admin, not a global mod, etc.

Give something like this a try:

[html]<a href="/">This is a link</a>[/html]

xtremecruiser

#29
Quote from: Mike Bobbitt on September 22, 2005, 02:51:50 PM
It works, but you have to be a true admin, not a global mod, etc.

Give something like this a try:

[html]<a href="/">This is a link</a>[/html]

Mike I got it, I just add the html tags, its been a long week, duh

<img src="http://www.simplemachines.org/community/Themes/simple/images/tl1.jpg" align="right">

Thanks

spiros

Is there some code one could add to subs.php for 1.1 RC3?

PTVDesign

#31
in subs

         array(
            'tag' => 'img',
            'type' => 'unparsed_content',
            'parameters' => array(
               'alt' => array('optional' => true),
               'width' => array('optional' => true, 'value' => ' width="$1"', 'match' => '(\d+)'),
               'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
               //moded by hxxp:ptvdesign.com [nonactive]
               'align' => array('optional' =>true, ' value' => ' align="$1"', 'match' => '(left|right|top|bottom|middle)'),
               //end mybe u need add vspace, hspace, border and others
            ),
            'content' => '<img src="$1" alt="{alt}"{width}{height} border="0" align="{align}" hspace="4" />',
            'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
            'disabled_content' => '($1)',
         ),
you need hxxp:webtmpl.com [nonactive]

Advertisement: