Clicking on images in comments, fancybox

Rishi B Posted in Component Development 6 years ago

I'm using the fancybox component to display images in a nice lightbox when clicked on. I was thinking that it would be nice if users could click on images in comments as well and get the same effect. I was able to do this by editing fancybox/plugins/default/fancybox.init.php - my version is here: https://gist.github.com/xbansh33/227b52ec2c62c528ed7b1f6738c54ef5

the problem I notice, however, is that when images for comments are stored, they're being resized, and it's therefore the small version that comes up in the fancybox when clicked. Is there an easy way to disable this resizing of images (or just resize using html elements rather than actually editing the image)?

Replies
se Johannes Genberg Replied 5 years ago

There seems to be something wrong when editing posts in 5.1 with this solution enabled. Hope you can find the problem and fix it :)

https://www.opensource-socialnetwork.org/discussion/view/3546/bug-blank-screen-when-you-edit-post-or-comments

German Michael Zülsdorff Replied 6 years ago

My vote for that change!
Actually I can't find no good reason for resizing any image unconditionally to 300px. Some people might even post smaller ones - and upsizing usually looks ugly.

us Rishi B Replied 6 years ago

keep in mind this will NOT work for previously uploaded images in comments (because they are resized at the time of upload).

us Rishi B Replied 6 years ago

I was able to figure out the issue with images in comments being resized. The following update to components/OssnComments/ossn_com.php will make sure that images being added to comments do NOT get resized. combined with the modification I explained in the OP, this will allow images within comments to load in a fancybox when clicked: https://gist.github.com/xbansh33/420040546a876a59d5644bfde6fafbcb

if you do still want a resized version of the image to be displayed in the comments, I suggest doing that with css/html instead of using the ossn-resize-image() function (which is what ossn_com.php originally did).