Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: bojzi on January 01, 2005, 08:14:28 AM

Title: wrap text around images
Post by: bojzi on January 01, 2005, 08:14:28 AM
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.
Title: Re: wrap text around images
Post by: [Unknown] on January 03, 2005, 04:19:48 AM
Can you post exactly how you're modifying Subs.php?

-[Unknown]
Title: Re: wrap text around images
Post by: bojzi on January 03, 2005, 05:11:09 AM
Quote'~\[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...
Title: Re: wrap text around images
Post by: [Unknown] on January 05, 2005, 04:07:24 AM
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]
Title: Re: wrap text around images
Post by: bojzi on January 05, 2005, 05:32:40 AM
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.
Title: Re: wrap text around images
Post by: Midgard on January 05, 2005, 05:34:19 AM
what's on line 1593? please copy-paste on here
Title: Re: wrap text around images
Post by: bojzi on January 05, 2005, 05:37:00 AM
This is copy-paste of the lines 1590-1595 after adding the mod:

Quote1590: // 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'])
Title: Re: wrap text around images
Post by: Midgard on January 05, 2005, 05:42:37 AM
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...
Title: Re: wrap text around images
Post by: bojzi on January 05, 2005, 05:48:56 AM
No, nothing yet...

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

Quote1596:{
1597: $context['user']['messages'] ']= &$user_info['messages'];
1598: $context['user']['unread_messages'] ']= &$user_info['unread_messages'];
Title: Re: wrap text around images
Post by: Midgard on January 05, 2005, 05:51:33 AM
Ums, i guess, your Subs.php crashed... whether again upload Subs.php from 'ZERO' :P or 'I don't know...'


[Unknown] help we :)
Title: Re: wrap text around images
Post by: bojzi on January 05, 2005, 06:13:40 AM
hey, i did it :)
thanks very much for your help guys...

looks like my subs.php did have some
Quote'];
extra groups of these signs... dunno why, but now it's workin ;) thanks! :)
Title: Re: wrap text around images
Post by: Midgard on January 05, 2005, 06:14:57 AM
Congratulations! :)
Title: Re: wrap text around images
Post by: [Unknown] on January 05, 2005, 06:32:27 PM
Are you using Dreamweaver?

-[Unknown]
Title: Re: wrap text around images
Post by: bojzi on January 06, 2005, 06:23:47 PM
yep :)
Title: Re: wrap text around images
Post by: James Woodcock on January 14, 2005, 05:24:11 AM
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?
Title: Re: wrap text around images
Post by: [Unknown] on January 17, 2005, 04:35:35 PM
Of course, just make this:

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

This instead:

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

-[Unknown]
Title: Re: wrap text around images
Post by: nameless on April 27, 2005, 08:47:10 PM
I am getting the following error

QuoteParse 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]
Title: Re: wrap text around images
Post by: [Unknown] on April 27, 2005, 08:48:19 PM
Are you using the "faster parsecode" mod?

-[Unknown]
Title: Re: wrap text around images
Post by: nameless on April 27, 2005, 11:24:29 PM
Quote from: [Unknown] on April 27, 2005, 08:48:19 PM
Are you using the "faster parsecode" mod?

-[Unknown]

yes
Title: Re: wrap text around images
Post by: wildcard on June 29, 2005, 04:34:00 AM
Quote from: [Unknown] on January 05, 2005, 04:07:24 AM
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?
Title: Re: wrap text around images
Post by: [Unknown] on July 14, 2005, 05:33:29 PM
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]
Title: Re: wrap text around images
Post by: crappyday on October 27, 2006, 05:23:16 AM
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>',
),
Title: Re: wrap text around images
Post by: chosenfool on November 16, 2006, 08:22:26 PM
Quote from: crappyday on October 27, 2006, 05:23:16 AM
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.
Title: Re: wrap text around images
Post by: Sandmansa on April 20, 2008, 12:42:34 AM
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?
Title: Re: wrap text around images
Post by: Fiery on June 17, 2008, 01:53:58 AM
Quote from: Sandmansa on April 20, 2008, 12:42:34 AM
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?
Title: Re: wrap text around images
Post by: Rockas on March 06, 2009, 05:35:55 AM
I know this is an old topic but... anyone knows something similar for the 2.0 version of SMF?
thank you
Title: Re: wrap text around images
Post by: Dragooon on April 24, 2009, 06:12:59 AM
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.
Title: Re: wrap text around images
Post by: thefley on September 05, 2009, 06:01:23 PM
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
Title: Re: wrap text around images
Post by: Arantor on September 05, 2009, 07:25:55 PM
Actually that mod should work just fine on 1.1.10 - just try installing it as usual (with backup first etc)
Title: Re: wrap text around images
Post by: thefley on September 05, 2009, 08:39:02 PM
Quote from: Arantor on September 05, 2009, 07:25:55 PM
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
Title: Re: wrap text around images
Post by: Arantor on September 05, 2009, 08:46:25 PM
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.
Title: Re: wrap text around images
Post by: thefley on September 06, 2009, 10:22:12 AM
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...

Title: Re: wrap text around images
Post by: Tyrsson on September 23, 2009, 08:08:49 AM
Is this solved or do you still require assistance on this issue?
Title: Re: wrap text around images
Post by: thefley on September 24, 2009, 12:07:04 PM
it is solved for me! thanks it works great
Title: Re: wrap text around images
Post by: naiTao on September 29, 2009, 08:55:04 AM
it works for me thanks.
Title: Re: wrap text around images
Post by: Arantor on October 10, 2009, 08:15:59 AM
Good to see it's working for people.
Title: Re: wrap text around images
Post by: MultiformeIngegno on December 06, 2009, 07:59:34 AM
I think it's a REALLY USEFUL feature!! Why don't add it by default? :D
Title: Re: wrap text around images
Post by: Arantor on December 06, 2009, 08:08:07 AM
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.
Title: Re:
Post by: MultiformeIngegno on December 06, 2009, 09:27:04 AM
Just because they're 5 lines why don't add 'em? And I think that a really lot of users will like this feature!
Title: Re: wrap text around images
Post by: Arantor on December 06, 2009, 11:04:55 AM
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.
Title: Re: wrap text around images
Post by: MultiformeIngegno on December 06, 2009, 01:04:52 PM
Quote from: Arantor on December 06, 2009, 11:04:55 AM
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!
Title: Re: wrap text around images
Post by: Arantor on December 06, 2009, 01:08:33 PM
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.
Title: Re: wrap text around images
Post by: SNBlog on December 28, 2009, 08:34:13 PM
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) :)
Title: Re: wrap text around images
Post by: zarej on February 22, 2010, 09:09:36 AM
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']
),
Title: Re: wrap text around images
Post by: Arantor on February 22, 2010, 11:35:34 AM
Please use [code] instead of [quote], it will help people to understand what you're saying - right now it's broken.
Title: Re: wrap text around images
Post by: zarej on February 23, 2010, 09:51:48 AM
I replaced to code. Anyway I missed topic hint is for this mod http://www.simplemachines.org/community/index.php?topic=147006.40