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

baseurl missing for local emoji #13

Open
Sora1248 opened this issue Jan 13, 2018 · 1 comment · May be fixed by #15
Open

baseurl missing for local emoji #13

Sora1248 opened this issue Jan 13, 2018 · 1 comment · May be fixed by #15

Comments

@Sora1248
Copy link

My blog isn't located at the root of my webspace but in a subdirectory. So I've set the baseurl accordingly in my _config.yml.
After installing your plugin and trying to use emoji from a local directory instead of including them from GitHub I've noticed that the plugin correctly found the image files in the local directory but generated the wrong URL for the img-tags: The baseurl-part of the URL was missing.
Adding the baseurl to emoji-images-path didn't work either as the look up of the local image files failed that way.

As a start here's my quick&dirty patch:

diff --git a/_plugins/emoji_for_jekyll.rb b/_plugins/emoji_for_jekyll.rb
index 39eb05d..1d0f04b 100644
--- a/_plugins/emoji_for_jekyll.rb
+++ b/_plugins/emoji_for_jekyll.rb
@@ -38,7 +38,7 @@ module EmojiForJekyll
         Dir.foreach(images_dir) do |image_filename|
           if /^(?<tag>.*)\.(?:svg|png|jpg|jpeg|gif)/ =~ image_filename
             @master_whitelist << tag
-            @images_path[tag] = File.join("/", images_path, image_filename)
+            @images_path[tag] = File.join("/", site.config["baseurl"], images_path, image_filename)
           end
         end

This solved the problem for me but obviously needs some additional checking if baseurl exists at all.

Sorry for not just providing a merge request with a final solution, but I don't really know Ruby and just don't want to deliver a botched C++-style solution. 😉

@yihangho
Copy link
Owner

@Sora1248 This looks good. Can you please turn this into a merge request? I guess the only change needed here is to do something like

baseurl = site.config["baseurl"] || ""

and pass it into File.join.

@Sora1248 Sora1248 linked a pull request Jan 29, 2018 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants