Neuigkeiten:

Join the Facebook Fan Page.

Hauptmenü
Advertisement:

wrap text around images

Begonnen von bojzi, Januar 01, 2005, 08:14:28 VORMITTAG

Vorheriges Thema - Nächstes Thema

bojzi

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.
The mind is like a parachute, it only works if it's open.

[Unknown]

Can you post exactly how you're modifying Subs.php?

-[Unknown]

bojzi

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...
The mind is like a parachute, it only works if it's open.

[Unknown]

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]

bojzi

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 if you need it...

Edit: Oh yeah, the Subs.php is totally unmodified, no additional stuff added to it.
The mind is like a parachute, it only works if it's open.

Midgard

what's on line 1593? please copy-paste on here

bojzi

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'])
The mind is like a parachute, it only works if it's open.

Midgard

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...

bojzi

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'];
The mind is like a parachute, it only works if it's open.

Midgard

Ums, i guess, your Subs.php crashed... whether again upload Subs.php from 'ZERO' :P or 'I don't know...'


[Unknown] help we :)

bojzi

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! :)
The mind is like a parachute, it only works if it's open.

Midgard


[Unknown]

Are you using Dreamweaver?

-[Unknown]

bojzi

The mind is like a parachute, it only works if it's open.

James Woodcock

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?

[Unknown]

Of course, just make this:

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

This instead:

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

-[Unknown]

nameless

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]

Skate, Snow, and Surf - SF Boarders - Bringing San Francisco Bay Area boarders together.

[Unknown]

Are you using the "faster parsecode" mod?

-[Unknown]

nameless


Skate, Snow, and Surf - SF Boarders - Bringing San Francisco Bay Area boarders together.

wildcard

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?

[Unknown]

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]

crappyday

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>',
),
 


chosenfool

#22
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.
hxxp:www.chosenfool.com/forums/index.php [nonactive]

Sandmansa

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?

Fiery

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?

Rockas

I know this is an old topic but... anyone knows something similar for the 2.0 version of SMF?
thank you

Dragooon

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.

thefley

#27
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

www.greatplainsriders.com

Arantor

Actually that mod should work just fine on 1.1.10 - just try installing it as usual (with backup first etc)
Holder of controversial views, all of which my own.


thefley

#29
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

www.greatplainsriders.com

Arantor

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.
Holder of controversial views, all of which my own.


thefley

#31
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...


www.greatplainsriders.com

Tyrsson

Is this solved or do you still require assistance on this issue?
PM at your own risk, some I answer, if they are interesting, some I ignore.

thefley

it is solved for me! thanks it works great

www.greatplainsriders.com

naiTao


Arantor

Good to see it's working for people.
Holder of controversial views, all of which my own.


MultiformeIngegno

I think it's a REALLY USEFUL feature!! Why don't add it by default? :D
RockCiclopedia (wiki - forum), Tutta la storia del rock, scritta da voi ...
Rimanere aggiornati sul mondo della musica grazie al nuovo feed "RockCiclopedia Music News"!

Arantor

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.
Holder of controversial views, all of which my own.


MultiformeIngegno

Just because they're 5 lines why don't add 'em? And I think that a really lot of users will like this feature!
RockCiclopedia (wiki - forum), Tutta la storia del rock, scritta da voi ...
Rimanere aggiornati sul mondo della musica grazie al nuovo feed "RockCiclopedia Music News"!

Arantor

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.
Holder of controversial views, all of which my own.


MultiformeIngegno

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!
RockCiclopedia (wiki - forum), Tutta la storia del rock, scritta da voi ...
Rimanere aggiornati sul mondo della musica grazie al nuovo feed "RockCiclopedia Music News"!

Arantor

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.
Holder of controversial views, all of which my own.


L'AltroWeb

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) :)

zarej

#43
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']
),

Arantor

Please use [code] instead of [quote], it will help people to understand what you're saying - right now it's broken.
Holder of controversial views, all of which my own.


zarej


Advertisement: