This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » legacy support » symfony 1.2 » Problem : Display img tag instead of the picture
Problem : Display img tag instead of the picture [message #78724] Wed, 20 May 2009 11:07 Go to next message
xzibit  is currently offline xzibit
Messages: 27
Registered: March 2009
Junior Member
Hi all,

I have a problem displaying image in a form using the admin generator.

In the backoffice it display this : <img class="media" src=" /uploads/images/c3c55ce5347bb702bc20dde662c4fb9962bfedfa.jpg " /> instead of displaying the image.

The code used to do this is this function coded in a class Media :

public function getImgResized()
    return '<img class="media" src="'.$this->getUrlResized().'" />';

public function getUrlResized()
    return "/uploads/images/".$this->getMediaPath();

And in the generator.yml of the module Media I have this :

      actions: ~
      fields:  ~
        layout:  stacked      
        display: [id,title,description]
        params:  |
      filter:  ~
      form:    ~
      edit:    ~
      new:     ~

I don't know why it display the html code while in another project it works fine using the same method.

Perhaps I have forget something ?!

Note (important I think) : in the result HTML code of the page I can see that :

<td colspan="8">
&lt;img class=&quot;media&quot; src=&quot;/uploads/images/c3c55ce5347bb702bc20dde662c4fb 9962bfedfa.jpg&quot; /&gt;</td>

The special characters are in HTML. But why ?
Re: Problem : Display img tag instead of the picture [message #101445 is a reply to message #78724 ] Tue, 22 June 2010 19:38 Go to previous messageGo to next message
oscarml  is currently offline oscarml
Messages: 11
Registered: May 2010
Junior Member

did you manage to find the solution?
Re: Problem : Display img tag instead of the picture [message #101476 is a reply to message #78724 ] Wed, 23 June 2010 11:01 Go to previous message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
This has been turned into htmlentities for you by symfony, as a security precaution. Rather than returning html from your model - which really belongs in the view anyway - create a partial and refer to it in your generator by preceding its name with an underscore. You can then add an image in there, I think.

Remember Palestine
Previous Topic:session handling
Next Topic:Form Validation - No error but not valid!?
Goto Forum:

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software