paginagmbh / redmine_lightbox2

Lightbox for image attachments in Redmine
MIT License
126 stars 97 forks source link

support in knowledgebase plugin #57

Closed GremL1N closed 5 years ago

GremL1N commented 6 years ago

Lightbox works fine in wiki, but in knowledgebase doesn't work at all. All preview links suggest download img instead popup preview or direct link to show img. Can you fix it or direct me in wich file i need to solve this problem/

tofi86 commented 6 years ago

I haven't used this plugin before. Can you please post some screenshots and mark the placed where the lightbox should be working?

I haven't got much time lately to work on enhancements here as I'm a new dad.

So if you can write JavaScript and know jQuery, you can take a look at these lines here https://github.com/paginagmbh/redmine_lightbox2/blob/master/assets/javascripts/lightbox.js#L78-L91 and add CSS selectors for the images you'd like to view in a lightbox and then send the changes as a pullrequest.

If the knowlegebase plugin doesn't provide consistent classes for images or doesn't mention the filename in the href or title attribute, you would have to tweak those elements first, as you can see in some examples at the beginning of the file where I add thumbnail classes or tweak elements to work properly.

GremL1N commented 6 years ago

thanx for response. I'm found that attachment.js not included in <head> section on knowledgebase articles. I'm add ArticleController to hook, and all works fine.

git diff
diff --git a/lib/hooks/view_layouts_base_html_head_hook.rb b/lib/hooks/view_layouts_base_html_head_hook.rb
index 2d82d7a..4fed18e 100644
--- a/lib/hooks/view_layouts_base_html_head_hook.rb
+++ b/lib/hooks/view_layouts_base_html_head_hook.rb
@@ -8,7 +8,8 @@ module RedmineLightbox2
                                       context[:controller].is_a?(DocumentsController) ||
                                       context[:controller].is_a?(FilesController) ||
                                       context[:controller].is_a?(MessagesController) ||
-                                      context[:controller].is_a?(NewsController))
+                                      context[:controller].is_a?(NewsController) ||
+                                     context[:controller].is_a?(ArticlesController))
           return stylesheet_link_tag("jquery.fancybox-2.1.5.css", :plugin => "redmine_lightbox2", :media => "screen") +
             stylesheet_link_tag("lightbox.css", :plugin => "redmine_lightbox2", :media => "screen") +
             javascript_include_tag('jquery.fancybox-2.1.5.pack.js', :plugin => 'redmine_lightbox2') +

I haven't got much time lately to work on enhancements here as I'm a new dad.

Congrats!

tofi86 commented 6 years ago

Awesome, thanks for having a look and chasing the issue down to the plugin hook!

I will certainly add this to the next release in a couple of weeks. Please bear with me ;-)

GremL1N commented 6 years ago

I'm glad to help usefull plugin. Thanx for your work.

zoeeer commented 6 years ago

Thanks guys! I'm also using the knowledgebase plugin and this certainly helped.

tofi86 commented 5 years ago

Support for alexbevi/redmine_knowledgebase plugin has been added. Can anyone test the redmine-3.4 branch in Redmine 3.4 or the master branch in Redmine 4.0 and confirm that it works? Thanks!

tofi86 commented 5 years ago

FYI: I just added support for Redmine 4.0 on the master branch and moved the code for Redmine 3.4 to another branch redmine-3.4.

This fix is available for Redmine 4.0 on master branch and Redmine 3.4 on redmine-3.4 branch.