[web2py] Re: Display Image in text

2012-09-11 Thread BlueShadow
thanks Massimo. that works. Is it also possible to make the image 
float:left or right So the text flowes around the image.
I tried adding float:left; to the _style but it doesnt have any effect.

On Tuesday, September 11, 2012 8:50:56 PM UTC+2, Massimo Di Pierro wrote:
>
> You should be able to do:
>
> {{
> if Article.InTextImage.thumb:
>src = URL('download',args=Article.InTextImage.thumb)
>content 
> = 
> Article.Content.replace('<>',IMG(_src=src,_style='display:block;').xml())
> else:
>content = Article.Content.replace('<>','')
> pass
> =XML(content, sanitize=True) # sanitize=True is optional but recommended
> }}
>
>
>
> On Tuesday, 11 September 2012 11:51:42 UTC-5, BlueShadow wrote:
>>
>> It does contain HTML for formatting. I display it by this line: 
>> {{=XML(Article.Content)}} to be exact
>>
>> On Tuesday, September 11, 2012 6:49:40 PM UTC+2, Massimo Di Pierro wrote:
>>>
>>> It depends. Does content contain HTML?
>>>
>>> On Tuesday, 11 September 2012 11:36:02 UTC-5, BlueShadow wrote:

 So what is the right way to do it?

 On Tuesday, September 11, 2012 6:15:29 PM UTC+2, Massimo Di Pierro 
 wrote:
>
> You should not do it that way because the value of content would be 
> escaped.
>
>

-- 





[web2py] Re: Display Image in text

2012-09-11 Thread Massimo Di Pierro
You should be able to do:

{{
if Article.InTextImage.thumb:
   src = URL('download',args=Article.InTextImage.thumb)
   content 
= 
Article.Content.replace('<>',IMG(_src=src,_style='display:block;').xml())
else:
   content = Article.Content.replace('<>','')
pass
=XML(content, sanitize=True) # sanitize=True is optional but recommended
}}



On Tuesday, 11 September 2012 11:51:42 UTC-5, BlueShadow wrote:
>
> It does contain HTML for formatting. I display it by this line: 
> {{=XML(Article.Content)}} to be exact
>
> On Tuesday, September 11, 2012 6:49:40 PM UTC+2, Massimo Di Pierro wrote:
>>
>> It depends. Does content contain HTML?
>>
>> On Tuesday, 11 September 2012 11:36:02 UTC-5, BlueShadow wrote:
>>>
>>> So what is the right way to do it?
>>>
>>> On Tuesday, September 11, 2012 6:15:29 PM UTC+2, Massimo Di Pierro wrote:

 You should not do it that way because the value of content would be 
 escaped.



-- 





[web2py] Re: Display Image in text

2012-09-11 Thread BlueShadow
It does I display it by this line to be exact: {{=XML(Artical.Content)}}

On Tuesday, September 11, 2012 6:49:40 PM UTC+2, Massimo Di Pierro wrote:
>
> It depends. Does content contain HTML?
>
> On Tuesday, 11 September 2012 11:36:02 UTC-5, BlueShadow wrote:
>>
>> So what is the right way to do it?
>>
>> On Tuesday, September 11, 2012 6:15:29 PM UTC+2, Massimo Di Pierro wrote:
>>>
>>> You should not do it that way because the value of content would be 
>>> escaped.
>>>
>>>

-- 





[web2py] Re: Display Image in text

2012-09-11 Thread Massimo Di Pierro
It depends. Does content contain HTML?

On Tuesday, 11 September 2012 11:36:02 UTC-5, BlueShadow wrote:
>
> So what is the right way to do it?
>
> On Tuesday, September 11, 2012 6:15:29 PM UTC+2, Massimo Di Pierro wrote:
>>
>> You should not do it that way because the value of content would be 
>> escaped.
>>
>>

-- 





[web2py] Re: Display Image in text

2012-09-11 Thread BlueShadow
So what is the right way to do it?

On Tuesday, September 11, 2012 6:15:29 PM UTC+2, Massimo Di Pierro wrote:
>
> You should not do it that way because the value of content would be 
> escaped.
>
>

-- 





[web2py] Re: Display Image in text

2012-09-11 Thread Massimo Di Pierro
You should not do it that way because the value of content would be escaped.

On Tuesday, 11 September 2012 10:53:18 UTC-5, BlueShadow wrote:
>
> Hi I like to have an Image Displayed within the Content of an Article. The 
> Content ist stored in a db table.
> Up till now I simply displayed the content by this line 
> {{Article.Content}} 
> I thought an image with text flowing around the image would freshen up the 
> article.
> I tried the following I put somewhere in the content of my article 
> <> and replace that Tag with the image. 
> {{import string}}
> {{try:}}
> {{content=string.replace(Article.Content, "<>", 
> "IMG(_src=URL(r=request, c='default', 
> f='download',args=Article.InTextImage.thumb),_style='display:block;')")}}
> {{except:}}
> {{content=string.replace(Article.Content, "<>", "")}}
> {{pass}}
> {{=content}}
> I put the whole part into a try clause so no errors are raised when There 
> is no Image stored for an Article.
> What happens is that every time the except part is executed only removing 
> my tag.
> Is it even possible to do put the Image in a Text that way?
>

--