Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I add width and height to IMG element after converting with emojione.toImage(value) #444

Open
stkol76 opened this issue Dec 17, 2021 · 0 comments

Comments

@stkol76
Copy link

stkol76 commented Dec 17, 2021

Hi,

I have to add width="" and height="" to each IMG element after I have converted the emoji tags to images with emojione.toImage(value) , since the standard size does not fit, and unfortunately, in this case, img.emojione {width: 20px !important; height: 20px !important;} (testet) has no effect since I have to use the output HTML in an HTML e-mail that should be viewable in Outlook.

Here is my code:

$("#UserSpecificMessageText").change(function () {                //INPUT FIELD WITH EMOJIONEAREA //
  var value = $(this).val();
  value = emojione.toImage(value);

  // HERE I NEED TO ADD WIDTH AND HEIGHT PROPERTY TO EACH IMG ELEMENT //
                                          
  $("#UserSpecificMessageTextToEmail").val(value);               // ANOTHER INPUT (HIDDEN) FIELD FOR FORM THAT SEND E-MAIL //
});

I have tried different variation of adding this property, but nothing works:

Examples of what I have tried:

    value = $('.img').each(function(index) {
       $(this).attr('width', '50px');                                          // This Returns [object object] that I can not convert back//
    });
   
   $(value).find(img).attr("width", "20").attr("height", "20");         // This gives me Uncaught TypeError: value.attr is not a function
   
   $(value).find(img).width(20).height(20);                                  // This gives me Uncaught TypeError: value.attr is not a function

  value = value["attr"]("img","width='20'");                                // This gives me Uncaught TypeError: value.attr is not a function

Maybe theres another way? Any help is appriciated :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant