-
Notifications
You must be signed in to change notification settings - Fork 16
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
Full URLs for displaying Emoji in email #13
Comments
Hi @justinthiele! This is possible, but you'd have to make a slight modification to the gem's code. If you change this line to use emoji_url = asset_url("emojis/#{file_name}")
%{<img src="#{emoji_url}" class="emoji" } +
%{title="#{emoji_code}" alt="#{emoji_code}" #{default_size}>} Or if you want to go above and beyond, allowing anyone to customize the emoji output, you could add an extra param to the initializer: markdown = Redcarpet::Markdown.new(MdEmoji::Render,
:no_intra_emphasis => true,
:replace_emoji => lambda {|emoji, emoji_file_name| "<strong>#{emoji}</strong>" }
) and then modify def replace_emoji(text)
text.gsub(/:([^\s:])+:/) do |emoji|
emoji_code = emoji #.gsub("|", "_")
emoji = emoji_code.gsub(":", "")
if MdEmoji::EMOJI.include?(emoji)
file_name = "#{emoji.gsub('+', 'plus')}.png"
return @custom_replace_emoji.call(emoji, file_name) if @custom_replace_emoji
default_size = %{height="20" width="20"}
%{<img src="/assets/emojis/#{file_name}" class="emoji" } +
%{title="#{emoji_code}" alt="#{emoji_code}" #{default_size}>}
else
emoji_code
end
end
end Just note you'd also need to capture the new argument in Personally I'm leaning towards the last option as it a) doesn't break the existing API and functionality and b) it allows much greater flexibility of the output emoji code. Let me know if you feel like this is something you feel comfortable undertaking. Take a look at our CONTRIBUTING.md file for info on how to submit a patch. Thanks! |
Hey @jordanbyron, thanks for the thorough response! I had trouble getting Option A to work. I get a It sounds like Option B might be the better way to go, unfortunately it's above my novice head. As an interim (and terribly smelly) solution, I hard coded the URL. 💩 Really appreciate your help anyway! 👍 |
Ah that's what I get for writing code on my iPad while lounging on the couch 😜 Don't sweat hardcoding the url. Whatever gets the job done. I'll leave this issue open as a reminder for me to implement this feature. Once it's done I'll ping you. ⛵ |
Awesome, thanks @jordanbyron! |
Is there a way to have the full URL used in the image link instead of just the path? I'd like to be able to use Emoji in notification emails. Thanks!
The text was updated successfully, but these errors were encountered: