Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Thema gestartet von: bojzi in Januar 01, 2005, 08:14:28 VORMITTAG

Titel: wrap text around images
Beitrag von: bojzi in Januar 01, 2005, 08:14:28 VORMITTAG
http://www.simplemachines.org/community/index.php?topic=19066.0

the problem is stated here... I want to be able to post images that have text wrapped around them. When i change subs.php the way that [unknown] said in the post above, i get an error... any ideas? thanks...


How to do it:
Sources/Subs.php, find:
// Size the font.  [size=large]HELLO![/size]
Add above it:
// Floating text/images...
'~\[float=(right|left)\](.+?)\[/float\]~' => '<div style="float: $1;">$2</div>',


Then you can use:
IMAGE HERE
Some text....


Moderator edit: added how to.
Titel: Re: wrap text around images
Beitrag von: [Unknown] in Januar 03, 2005, 04:19:48 VORMITTAG
Can you post exactly how you're modifying Subs.php?

-[Unknown]
Titel: Re: wrap text around images
Beitrag von: bojzi in Januar 03, 2005, 05:11:09 VORMITTAG
Zitat'~\[float=(right|left)\](.+?)\[/float\]~' => '<div style="float: $1;">$2</div>',

And change:
'~\[hr(?:\s*/)?\]~i' => isset($disabled['hr']) ? '' : '<hr style="clear: both;" />',
'~\[br(?:\s*/)?\]~i' => '<br style="clear: both;" />',

This is what you wrote in the post about wrapping the text...

well, i just added the first line and found the two lines (hr, br) that had the same beginning, and changed them with the two lines that you wrote...
Titel: Re: wrap text around images
Beitrag von: [Unknown] in Januar 05, 2005, 04:07:24 VORMITTAG
Sources/Subs.php, find:

// Size the font.  [size=large]HELLO![/size]

Add above it:

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


Then you can use:

IMAGE HERE
Some text....

-[Unknown]
Titel: Re: wrap text around images
Beitrag von: bojzi in Januar 05, 2005, 05:32:40 VORMITTAG
thanks for your help, but i get that error again :(

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/bojzi/public_html/forum/Sources/Subs.php on line 1593

phpinfo (http://www.freestylekings.org/phpinfo.php) if you need it...

Edit: Oh yeah, the Subs.php is totally unmodified, no additional stuff added to it.
Titel: Re: wrap text around images
Beitrag von: Midgard in Januar 05, 2005, 05:34:19 VORMITTAG
what's on line 1593? please copy-paste on here
Titel: Re: wrap text around images
Beitrag von: bojzi in Januar 05, 2005, 05:37:00 VORMITTAG
This is copy-paste of the lines 1590-1595 after adding the mod:

Zitat1590: // Gotta be special for the javascript.
1591: $context['fader_news_lines'][$i] = strtr(addslashes($context['news_lines'][$i]), array('/' => '\/', '<a href=' => '<a hre" + "f='));
1592: }
1593: $context['random_news_line'] ']= $context['news_lines'][rand(0, count($context['news_lines']) - 1)];
1594:
1595: if (!$user_info['is_guest'])
Titel: Re: wrap text around images
Beitrag von: Midgard in Januar 05, 2005, 05:42:37 VORMITTAG
Replace with:
// Gotta be special for the javascript.
$context['fader_news_lines'][$i] = strtr(addslashes($context['news_lines'][$i]), array('/' => '\/', '<a href=' => '<a hre" + "f='));
}
$context['random_news_line'] = $context['news_lines'][rand(0, count($context['news_lines']) - 1)];

if (!$user_info['is_guest'])


Please try again...
Titel: Re: wrap text around images
Beitrag von: bojzi in Januar 05, 2005, 05:48:56 VORMITTAG
No, nothing yet...

Zitat
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/bojzi/public_html/forum/Sources/Subs.php on line 1597

Zitat1596:{
1597: $context['user']['messages'] ']= &$user_info['messages'];
1598: $context['user']['unread_messages'] ']= &$user_info['unread_messages'];
Titel: Re: wrap text around images
Beitrag von: Midgard in Januar 05, 2005, 05:51:33 VORMITTAG
Ums, i guess, your Subs.php crashed... whether again upload Subs.php from 'ZERO' :P or 'I don't know...'


[Unknown] help we :)
Titel: Re: wrap text around images
Beitrag von: bojzi in Januar 05, 2005, 06:13:40 VORMITTAG
hey, i did it :)
thanks very much for your help guys...

looks like my subs.php did have some
Zitat'];
extra groups of these signs... dunno why, but now it's workin ;) thanks! :)
Titel: Re: wrap text around images
Beitrag von: Midgard in Januar 05, 2005, 06:14:57 VORMITTAG
Congratulations! :)
Titel: Re: wrap text around images
Beitrag von: [Unknown] in Januar 05, 2005, 06:32:27 NACHMITTAGS
Are you using Dreamweaver?

-[Unknown]
Titel: Re: wrap text around images
Beitrag von: bojzi in Januar 06, 2005, 06:23:47 NACHMITTAGS
yep :)
Titel: Re: wrap text around images
Beitrag von: James Woodcock in Januar 14, 2005, 05:24:11 VORMITTAG
Great little trick, however can you alter the code to add a bit of a margin around the image so the text isnt flush with the edge of the image?
Titel: Re: wrap text around images
Beitrag von: [Unknown] in Januar 17, 2005, 04:35:35 NACHMITTAGS
Of course, just make this:

'<div style="float: $1;">$2</div>

This instead:

'<div style="float: $1; margin: 1ex;">$2</div>

-[Unknown]
Titel: Re: wrap text around images
Beitrag von: nameless in April 27, 2005, 08:47:10 NACHMITTAGS
I am getting the following error

ZitatParse error: parse error, unexpected T_DOUBLE_ARROW in /home/sfboarders/public_html/nameless/forum/Sources/Subs.php on line 1015

Lines 1014-1016 below

// Floating text/images...
'~\[float=(right|left)\](.+?)\[/float\]~' => '<div style="float: $1;">$2</div>',
// Size the font.  [size=large]HELLO![/size]
Titel: Re: wrap text around images
Beitrag von: [Unknown] in April 27, 2005, 08:48:19 NACHMITTAGS
Are you using the "faster parsecode" mod?

-[Unknown]
Titel: Re: wrap text around images
Beitrag von: nameless in April 27, 2005, 11:24:29 NACHMITTAGS
Zitat von: [Unknown] in April 27, 2005, 08:48:19 NACHMITTAGS
Are you using the "faster parsecode" mod?

-[Unknown]

yes
Titel: Re: wrap text around images
Beitrag von: wildcard in Juni 29, 2005, 04:34:00 VORMITTAG
Zitat von: [Unknown] in Januar 05, 2005, 04:07:24 VORMITTAG
Sources/Subs.php, find:

// Size the font.  [size=large]HELLO![/size]

Add above it:

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


Then you can use:

IMAGE HERE
Some text....

-[Unknown]

How would one achieve this in 1.1 now?
Titel: Re: wrap text around images
Beitrag von: [Unknown] in Juli 14, 2005, 05:33:29 NACHMITTAGS
Find in Subs.php:

array(
'tag' => 'ftp',
'type' => 'unparsed_content',
'content' => '<a href="$1" target="_blank">$1</a>',
'validate' => '$data = strtr($data, array(\'<br />\' => \'\'));',
),


Add before it:

array(
'tag' => 'float',
'type' => 'unparsed_equals',
'test' => '(left|right)\]',
'before' => '<div style="float: $1;">',
'after' => '</div>',
),


-[Unknown]
Titel: Re: wrap text around images
Beitrag von: crappyday in Oktober 27, 2006, 05:23:16 VORMITTAG
I know it's been a while since anyone posted in this, but I just did this to my forum and we're using 1.1 RC2 still and to add the margin it took a little guessing between the two codes but if anyone is interested its:

array(
'tag' => 'float',
'type' => 'unparsed_equals',
'test' => '(left|right)\]',
'before' => '<div style="float: $1; margin: 1ex;">',
'after' => '</div>',
),
Titel: Re: wrap text around images
Beitrag von: chosenfool in November 16, 2006, 08:22:26 NACHMITTAGS
Zitat von: crappyday in Oktober 27, 2006, 05:23:16 VORMITTAG
I know it's been a while since anyone posted in this, but I just did this to my forum and we're using 1.1 RC2 still and to add the margin it took a little guessing between the two codes but if anyone is interested its:

array(
'tag' => 'float',
'type' => 'unparsed_equals',
'test' => '(left|right)\]',
'before' => '<div style="float: $1; margin: 1ex;">',
'after' => '</div>',
),


SWEET!
Thanks for the code update! i can confirm this works in 1.1RC3. :)

Edit:

and as of 12/11/06, it still works well with 1.1Final.
Titel: Re: wrap text around images
Beitrag von: Sandmansa in April 20, 2008, 12:42:34 VORMITTAG
This works in 1.1.4 as well.  But I have a question.  How do I go about adding a center function where the text wraps to the left and to the right of a centered image?
Titel: Re: wrap text around images
Beitrag von: Fiery in Juni 17, 2008, 01:53:58 VORMITTAG
Zitat von: Sandmansa in April 20, 2008, 12:42:34 VORMITTAG
This works in 1.1.4 as well.  But I have a question.  How do I go about adding a center function where the text wraps to the left and to the right of a centered image?

Do you always want the image centered?

Have you tried using the center BB code?
Titel: Re: wrap text around images
Beitrag von: Rockas in März 06, 2009, 05:35:55 VORMITTAG
I know this is an old topic but... anyone knows something similar for the 2.0 version of SMF?
thank you
Titel: Re: wrap text around images
Beitrag von: Dragooon in April 24, 2009, 06:12:59 VORMITTAG
Hello Rockas, did you ever get this solved? If not, then I believe the same piece of code would work for SMF 2.0 RC 1 as well.
Titel: Re: wrap text around images
Beitrag von: thefley in September 05, 2009, 06:01:23 NACHMITTAGS
I loved this MOD!!!! now it will not work on 1.1.10.  after I moved forum...  I used this MOD almost every post..  can someone please update it!!!! PLEASE!!!!

and none of the package parse pages will open is so I can see to manually install it

http://custom.simplemachines.org/mods/index.php?mod=631
Titel: Re: wrap text around images
Beitrag von: Arantor in September 05, 2009, 07:25:55 NACHMITTAGS
Actually that mod should work just fine on 1.1.10 - just try installing it as usual (with backup first etc)
Titel: Re: wrap text around images
Beitrag von: thefley in September 05, 2009, 08:39:02 NACHMITTAGS
Zitat von: Arantor in September 05, 2009, 07:25:55 NACHMITTAGS
Actually that mod should work just fine on 1.1.10 - just try installing it as usual (with backup first etc)
your right, I had an old ver of it saved.  but I still get an error.  tried all the parse sites and not one will open it so I know what file to mod manually

HERE IS THE ERROR

Installing this package will perform the following actions:  Type Action Description
1. Execute Modification ./Themes/default/languages/Modifications.english.php Test successful  
2. Execute Modification ./Sources/Subs.php Test successful
3. Execute Modification ./Themes/default/Post.template.php Test failed  
4. Extract File ./Themes/default/images/bbc/float.gif


http://dev.smfchat.com/parser/index.php

and a few older ones I have tried as well
Titel: Re: wrap text around images
Beitrag von: Arantor in September 05, 2009, 08:46:25 NACHMITTAGS
I just went to the mod site for the link above - http://custom.simplemachines.org/mods/index.php?mod=631 - selected 1.1.10 in the dropdown for version and hit Parse, and it gave me all the edits to apply without any fuss.
Titel: Re: wrap text around images
Beitrag von: thefley in September 06, 2009, 10:22:12 VORMITTAG
thanks for all your help. but I still get the error.  I am on another computer trying it... here is what I get.


if you would not mind posting the code for the template I need to mod from above I would appreciate it.


Thanks, with your help, it helped me find the manual install off the site...

Titel: Re: wrap text around images
Beitrag von: Tyrsson in September 23, 2009, 08:08:49 VORMITTAG
Is this solved or do you still require assistance on this issue?
Titel: Re: wrap text around images
Beitrag von: thefley in September 24, 2009, 12:07:04 NACHMITTAGS
it is solved for me! thanks it works great
Titel: Re: wrap text around images
Beitrag von: naiTao in September 29, 2009, 08:55:04 VORMITTAG
it works for me thanks.
Titel: Re: wrap text around images
Beitrag von: Arantor in Oktober 10, 2009, 08:15:59 VORMITTAG
Good to see it's working for people.
Titel: Re: wrap text around images
Beitrag von: MultiformeIngegno in Dezember 06, 2009, 07:59:34 VORMITTAG
I think it's a REALLY USEFUL feature!! Why don't add it by default? :D
Titel: Re: wrap text around images
Beitrag von: Arantor in Dezember 06, 2009, 08:08:07 VORMITTAG
There are no plans to add this as a default feature, and it adds another five lines to the 1500 already in the bbcode system that the average forum user wouldn't really follow properly.
Titel: Re:
Beitrag von: MultiformeIngegno in Dezember 06, 2009, 09:27:04 VORMITTAG
Just because they're 5 lines why don't add 'em? And I think that a really lot of users will like this feature!
Titel: Re: wrap text around images
Beitrag von: Arantor in Dezember 06, 2009, 11:04:55 VORMITTAG
Because it's 5 lines that are called MANY times.

parse_bbc is one of the heaviest functions in SMF. It's called every post, called every message listing (for the first post in every thread), amongst others. Every line added slows that down - IMO we need to cut back not add more there.
Titel: Re: wrap text around images
Beitrag von: MultiformeIngegno in Dezember 06, 2009, 01:04:52 NACHMITTAGS
Zitat von: Arantor in Dezember 06, 2009, 11:04:55 VORMITTAG
parse_bbc is one of the heaviest functions in SMF. It's called every post, called every message listing (for the first post in every thread), amongst others. Every line added slows that down - IMO we need to cut back not add more there.
I agree, we can remove a lot of useless BBC! But now, that more than ever are growing portal/wiki/blog MODs, this tag is really useful! Yes, you can say that authors can add the tag in their MODs, but it's useful also for "normal" forum: long posts need some images floatting/text wrapping! I agree that performance is important, but there are a lot of useless tags that can be removed (and added, if admins want, with MODs), for example shadow/glow! float=left/right is - I think - a basic tag, not "stylish", it's important, not only "cool" (and useless) like shadow/glow!
Titel: Re: wrap text around images
Beitrag von: Arantor in Dezember 06, 2009, 01:08:33 NACHMITTAGS
Oh, I agree shadow, glow should go. I also think move and some of the others should go, but I cannot seriously see adding it.

I'm almost certain it *won't* be in 2.0. I strongly doubt it will be in 2.1 but I'll push for it.

The problem with removing features is that there are folk who will expect it to be there.
Titel: Re: wrap text around images
Beitrag von: L'AltroWeb in Dezember 28, 2009, 08:34:13 NACHMITTAGS
Hi :)
Actually i use this code to post my articles with float image

[html]
<img style="float: left;" src="h**p://mysite.*/imagename.jpg" alt="alt-text" title="title-text" />
[/html]

is there any way to add alt and title attribute to this mod?
i think a bbcode like this:
[img float=left alt="alternative text" title="images title"]h**p://mysite.*/imagename.jpg[/img]
(smf media gallery style) :)
Titel: Re: wrap text around images
Beitrag von: zarej in Februar 22, 2010, 09:09:36 VORMITTAG
Thanx for great mod.

Quick Tip for SMF 2 versions:
FIrst 2 steps are the same as in Instalation instructons for 1.1.6 but in 3rd step instead of editing  ./Themes/default/Post.template.php you must edit ./Sources/Subs-Editor:

Find:
array(
'image' => 'img',
'code' => 'img',
'before' => '[img]http://',
'after' => '[/img]',
'description' => $txt['image']
),

and Add Before:
array(
'image' => 'float',
'code' => 'float',
'before' => '[float=left][img]http://',
'after' => '[/img][/float]',
'description' => $txt['float']
),
Titel: Re: wrap text around images
Beitrag von: Arantor in Februar 22, 2010, 11:35:34 VORMITTAG
Please use [code] instead of [quote], it will help people to understand what you're saying - right now it's broken.
Titel: Re: wrap text around images
Beitrag von: zarej in Februar 23, 2010, 09:51:48 VORMITTAG
I replaced to code. Anyway I missed topic hint is for this mod http://www.simplemachines.org/community/index.php?topic=147006.40