Skip to content

Remove “\"” from img tags in SilverStripe

G12th March 2014

C1 Comment

TSilverStripe

A remedy for removing the erroneous inclusion of “\"” in img tags in SilverStripe.

A SilverStripe 3.1 website that I have been working on was recently migrated to a new server that supported PHP 5.3.27. I had previously followed these instructions for installing SilverStripe but on the new server the site responded with Error 500 (Internal Server Error). In order to remedy the Error 500, the following line had to be deleted from the .htaccess file on the root:

SetEnv PHPRC "/home/mysite/public_html/silverstripe/"

Like many content management systems, SilverStripe 3.1 uses the TinyMCE WYSIWYG editor to generate HTML output. Following the changes to .htaccess, I was unable to include images in new web pages that I created. The images would upload, but the resultant HTML would look like this:

<img class="\&quot;leftAlone\&quot;" title="\&quot;Cineraria\&quot;" src="\&quot;assets/Uploads/cineraria-senecio-cruentus.jpg\&quot;" alt="\&quot;cineraria\&quot;">

rather than this:

<img class="leftAlone" title="Cineraria" src="assets/Uploads/cineraria-senecio-cruentus.jpg" alt="cineraria">

Initially I assumed it to be a problem with TinyMCE but it turned out to be a problem with magic_quotes having been switched back on, despite my inclusion of a php.ini file in the root that turned it off. The removal of the line from .htaccess meant that magic_quotes was not switched off in all directories.

The remedy was to upload the following php.ini to the /framework directory, as per this suggestion:

magic_quotes_runtime = 0
magic_quotes_gpc = 0
magic_quotes_sybase = 0
get_magic_quotes_gpc = 0
display_errors = 0
date.timezone = Australia/Melbourne
memory_limit = 128M

The unwanted \&quot; were then no longer included within img tags – problem solved!

   

Comments:

One response to “Remove “\&quot;” from img tags in SilverStripe”

  • Written by radialgraphics on 15 May 2014:

    Hi Adam,

    I was pulling my hair out trying to figure this issue out on a new install of SilverStripe 3.1.5. Thanks so much for publishing your issue and your effective solution.

    Peter

Have your say:

The following HTML is permitted:
<a href="" title=""> <b> <blockquote cite=""> <code> <em> <i> <q cite=""> <strike> <strong>

Comments will be published subject to the Editorial Policy.