1
votes

I'm using this plugin for the TinyMCE wysiwyg editor.

The emoticons being added are 72x72 px, but I want them to be displayed as 20x20 px.

When you click a smiley from the list it creates an element inside the editor body like this:

<img title="smile" src="https://twemoji.maxcdn.com/2/72x72/1f600.png" data-mce-src="https://twemoji.maxcdn.com/2/72x72/1f618.png">

How do I would I add a style="width:20px" to it when it creates the element?

My TinyMCE init is:

  tinymce.init({
    selector: '.main-textarea',
    height: 300,
    menubar: "insert format",
    plugins: [
      'advlist lists link image charmap print preview hr anchor pagebreak',
      'searchreplace wordcount visualblocks visualchars code fullscreen',
      'insertdatetime media nonbreaking save table contextmenu directionality',
      'smileys template paste textcolor colorpicker textpattern imagetools'
    ],
    toolbar1: 'styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image media',
    toolbar2: 'forecolor smileys',
    smileys:[
     [
         { shortcut: ':)', url: 'https://twemoji.maxcdn.com/2/72x72/1f600.png', title: 'smile' },
         { shortcut: ':\')', url: 'https://twemoji.maxcdn.com/2/72x72/1f602.png', title: 'cwl' },
         { shortcut: ':*', url: 'https://twemoji.maxcdn.com/2/72x72/1f618.png', title: 'blowkiss' }
     ]
    ],
    auto_convert_smileys: true,
    image_advtab: true,
    content_css : "https://fonts.googleapis.com/css?family=Open+Sans:400,600"
   });

I've tried looking in the plugin source code to add a style but I nothing has worked for me.

2

2 Answers

0
votes

Was able to solve it. I unminified the source and at the bottom there is this:

n.addButton("smileys", {
    type: "panelbutton",
    icon: "emoticons",
    panel: {
        autohide: !0,
        html: e,
        onclick: function(t) {
            var i = n.dom.getParent(t.target, "a");
            i && (n.insertContent('<img src="' + i.getAttribute("data-mce-url") + '" title="' + i.getAttribute("title") + '" class="emoji" style="width:20px">'), this.hide())
        }
    },
    tooltip: "Smileys"
})

I added class="emoji" style="width:20px"

to

n.insertContent('<img src="' + i.getAttribute("data-mce-url") + '" title="' + i.getAttribute("title") + '" class="emoji" style="width:20px">')
0
votes

You could add a CSS class which matches the img title:

img[title=smile] {
    width: 20px;
}

Another solution would be to use images of size 20 x 20.