Description of issue or problem I’m having:
I have uploaded an image via TinyMCE to display in an announcement on the website. In the editor I scaled the image and can see in the editor source that the width and height attributes are being set correctly. On the frontend however when the announcement is being viewed, the image is not being scaled - it is being shown at full-size and with no width or height attributes at all.
Is TinyMCE stripping the width and height attributes from the img links??
Steps I took leading up to the issue:
Inserted an image into the TinyMCE editor as part of a new announcement record to be shown on the frontend.
What I tried to resolve the issue:
Nothing I do appears to correct the width and height of the inserted image.
Application Version - e.g., OJS 3.1.2:
Additional information, such as screenshots and error log messages if applicable:
The width and height are visible in the editor.
On the frontend, the image html looks like:
<img src="http://localhost/ojs/public/site/images/aforshaw/wrong-issue.png" alt="An image from the disk">
Could this be a setting within TinyMCE, or something to do with OJS itself?
Do you have Text Editor extras plugin installed (and announcements checked off in the settings)? That might allow you to bypass the stripping out of the HTML - not certain - but worth a try.
Thanks for your reply - good suggestion. I do have the plugin installed but everything is already checked. Could this be some kind of “bug”?
Are there any other ways to prevent the tags from being stripped out?
Darn… I was hoping that might address it. It does allow for the use of images, but not additional styling via HTML.
There is a bit of an explanation here on some of the rationale behind not allowing additional HTML through TinyMCE: Adding images to announcements in OJS 3.3 - Tiny MCE - #4 by rcgillis
But I wonder about some potential workarounds here:
You could try editing your
config.inc.php to have some additional allowed HTML:
"a[href|target|title],em,strong,cite,code,ul,ol,li[class],dl,dt,dd,b,i,u,img[src|alt|width|height],sup,sub,br,p (this is just an example I pulled - your settings might look different)
Another option to try might be a custom stylesheet CSS stylesheet, where you identify the image through an ID attribute. That said, even if you had an ID attribute - although - it’s entirely possible that if you used an
id or something similar in the HTML, that it would be stripped out.
Thank you very much Roger - I added the extra “width|height” to the allowed_html string and that has worked perfectly.
This topic was automatically closed after 3 days. New replies are no longer allowed.