JavaScript Add inline CSS in the image using TinyMCE inline image with text,inline image in email,inline image

I'm using Tiny MCE 4 for users posting on my website. It works very well, but the problem is that when a users puts an image in Tiny MCE, and changes its size, it generates the following line:

<img src="source/imagem.jpg?14641" alt="" width="550" height="838">

The result is a non responsive picture. How can I configure Tiny MCE to add the following inline css attributes on the image ?

<img src="source/imagem.jpg?14641" alt="" width="550" height="838" style="
    width: 100%; max-width: 550px; height: auto;">
Answer:1

Why not simply creating a CSS rule that adds the required attributes to all img elements of a particular container. For example, in a div element of class container, you can define the following CSS selector:

.container img {
    max-width:100%;
    height:auto;
}

Here is a sample of the result on a simple page. You can see that the yellow image is unchanged but all images contained in the container div children elements are resized (here the green and blue images).

.container img {
	max-width:100%;
	height:auto;
}
<img src="http://placehold.it/400x400/EEE04A/ffffff" />
<div class="container" style="width:150px;">
	<img src="http://placehold.it/800x300/5cb85c/ffffff" />
	<div>
		<img src="http://placehold.it/800x600/5bc0de/ffffff" />
	</div>
</div>
Answer:2

Add inline styles with '!important' and any image don't change size.

.tiny-mce-wrapper img {
    width: 100% !important;
	max-width:100% !important;
	height:auto !important;
}
Answer:3

You can use javascript (with jQuery) to handle this (without reconfiguring tinymce). You just have to include this into the page that is showing the images.

$(document).ready(function () {

    $('.Container').find('img').each(function () {

        var _this = $(this);

        _this.css({
            'width': _this.width,
            'height': _this.height
        });

        _this.removeAttr('width');
        _this.removeAttr('height');
    });
});
Answer:4

I'm looking to convert a basic click function into an AJAX call, but I am not sure how to do so with appended responses I have that are sent from my php script. How could I do this? I have the ...

I'm looking to convert a basic click function into an AJAX call, but I am not sure how to do so with appended responses I have that are sent from my php script. How could I do this? I have the ...

  1. jquery basic click function

I’m trying to change the background colors of a highcharts scatter plot. I can easily change the color of the section with this code below. However, I need change the background to more than one color....

I’m trying to change the background colors of a highcharts scatter plot. I can easily change the color of the section with this code below. However, I need change the background to more than one color....

  1. changing color background in photoshop
  2. changing color background css
  3. changing color background video
  4. changing color background
  5. changing color background html
  6. change color background instagram story
  7. change color background online
  8. change color background illustrator
  9. change color background photo online
  10. change color background image css
  11. change color background instagram
  12. change color background android studio
  13. change color background on text messages
  14. change color background photo
  15. change color background indesign
  16. change color background premiere pro
  17. change color background svg
  18. change color background ig story
  19. change color background app
  20. change color background maya

Why my code is unable to run and brower's console is producing error "JQuery is not defined" even though I am en-queuing my JavaScript file into the plugin properly. As per source code, JQuery ...

Why my code is unable to run and brower's console is producing error "JQuery is not defined" even though I am en-queuing my JavaScript file into the plugin properly. As per source code, JQuery ...

  1. wordpress uncaught referenceerror jquery is not defined
  2. wordpress uncaught referenceerror tinymce is not defined
  3. wordpress uncaught referenceerror $ is not defined
  4. wordpress uncaught referenceerror grecaptcha is not defined
  5. wordpress uncaught referenceerror columns is not defined
  6. wordpress uncaught referenceerror mejs is not defined
  7. wordpress uncaught referenceerror ajaxurl is not defined
  8. wordpress uncaught referenceerror google is not defined

I have an object such as: var dataObj = { 'hre': {groupID: 1}, 'bla': {groupID: 1}, 3: {groupID: 0}, 4: {groupID: 2}, 16: {groupID: 2}, 6: {groupID: 2}, 7: {groupID: 0}, 64893: {groupID: 0}, 9: {...

I have an object such as: var dataObj = { 'hre': {groupID: 1}, 'bla': {groupID: 1}, 3: {groupID: 0}, 4: {groupID: 2}, 16: {groupID: 2}, 6: {groupID: 2}, 7: {groupID: 0}, 64893: {groupID: 0}, 9: {...