Images in body

Hi All,

I need a way to place floated images into the body of an article. The
body is pulled from the database, so I need a way to scan a certain
number of words, or paragraphs, and then place an image_tag in there.

Thanks in advance for any help.

I'd recommend you look to another list (css-d for example) for help like this.

hth,
Bill

This isn't a css question. What I need to know is how to split up a
large amount of text into paragraphs, based on newlines (as entered in
a textarea) or the occurrence of a closing paragraph tag and an open
one, and insert imagetags in between them. Ideally, what I need is
the equivalent of php's substr_replace function.

This is probably a rudimentary question, but it's definitely not a css question.

This isn't a css question. What I need to know is how to split up a
large amount of text into paragraphs, based on newlines (as entered in
a textarea) or the occurrence of a closing paragraph tag and an open
one, and insert imagetags in between them. Ideally, what I need is
the equivalent of php's substr_replace function.

The equivalent function you're after is ruby's String gsub function which will replace stuff based on a regular expression:

content = content.gsub(/\<\/p\>\<p\>/, "<p>" << image_tag("myimage.jpg") << "</p>")

This is obviously a *very* contrived and buggy example, but it should demonstrate the concept. You can also modify a string in place using string.gsub!()

If you haven't already, I'd recommend you get the pragmatic programmers' 'Programming Ruby' book (otherwise known as the 'pickaxe'). It'll really take you further into ruby itself and help you easily solve problems like this.

Hope that helps,

Steve

That's great (both your solution and suggestion).

Thanks