Home
TeamSite
text align issue
nico
I've got an issue where the client wants to wrap text around the top and left of an image. But the image html needs to be placed in somewhere in the middle of the paragraph to format this correctly how is this done? Since the text is a value being pulled from ts, ts doesn't know where to break the text stick an <img> tag smack in the middle of the output and then resume feeding the text. Ideas?
Find more posts tagged with
Comments
Migrateduser
If you could devise a suitable algorithm, you could use a bit of iw_perl to divide the value from your text field into two parts, then rebuild it with the <img> tag in the middle. Very difficult to come up with an algorithm that will consistently give the result you want (e.g. it will almost certainly end up being dependent on the width of the browser window, length of words in the paragraph, etc.). If you wanted it to break right after a word, exactly half through the text, something like this should get you close (mind you, it's not terribly efficient):
my $foo = iwpt_get_dcr_value('dcr.Foo');
my $fooMidPoint = int(length($foo)/2);
$foo =~ /.{1,$fooMidPoint}\b(/*)/;
$newFoo = "$1<img src='" . iwpt_get_dcr_value(dcr.IMG) .
"'>" . $2;
Then later on, when you want to reference it:
<iw_value name='$newFoo'/>
Ugly, but it gets you in the ballpark and you might be able to tweak the division based upon your particular needs.
Cheers
Rob Huffstedtler
rob@bagpipe.com
nico
Rob,
Yeah sounds good, I was thinking the client may have to figure out a
maxcharlength then the paragraph would have to be broken in two. So <text
part 1 max length defined in here><img align code><text part 2 remaining
paragraph text>. My example does not reflect the actual ts code but rather
the concept.
Thanks for you input,
Nico