francoischalifour / medium-zoom

🔎🖼 A JavaScript library for zooming images like Medium
https://medium-zoom.francoischalifour.com
MIT License
3.64k stars 165 forks source link

Add an option to use custom class for zoomed image #152

Open kfeng0806 opened 4 years ago

kfeng0806 commented 4 years ago

The problem

I'd like to add custom style to the zoomed image, is there possible to add an option for zoom image.

For example:

mediumZoom('[data-zoomable]', {
  class: ['class1', 'class2', 'class3']
})

The result will be: <img src="image.jpg" data-zoom-src="image.jpg" class="medium-zoom-image medium-zoom-image--opened class1 class2 class3">

francoischalifour commented 4 years ago

Can't you add styles to .medium-zoom-image--opened?

kfeng0806 commented 4 years ago

Sometimes you only wish add the style in some scenes e.g.: I have user avatar on the page it has rounded border, so i'd like the zoomed avatar image also has consistent style but except other images.

kerns commented 4 years ago

This seems like it could be particularly useful in projects where functional css /e.g. tailwind/ are in use.

ImTheDeveloper commented 2 years ago

Can't you add styles to .medium-zoom-image--opened?

Yea - this is what I've done and seemed to work fine