I want to override lib/web/mage/gallery/gallery.less and some module files in


I need to override them because I want to change the style of product gallery images.

How to override or Are there any other way to "settle the question"?

2 Answers 2


We can override the less file lib in our custom theme. Put this file under web folder:


and add mage/gallery/gallery in PROJECT/dev/tools/grunt/configs/themes.js (or PROJECT/dev/tools/grunt/configs/local-themes/themes.js for magento 2.2) to make grunt compiling it as well.

  • Thanks you for answer, but I try it, seem it not work. I had already remove cache and static files, deploy again, It didn't work.
    – Mr Tim
    Commented Nov 26, 2016 at 14:06
  • 1
    You should read more: magento.stackexchange.com/questions/110164/… Commented Nov 26, 2016 at 16:24
  • Thanks a lot! But I read a check it agian, They are only work with less files in lib/web/css/source. Can you please help me check again?
    – Mr Tim
    Commented Nov 26, 2016 at 18:07
  • @MrTim you should try app/design/frontend/{Vendor}/{Theme}/web/css/source/lib/mage/gallery/gallery.less Commented Nov 28, 2016 at 7:28
  • Thanks in advanced. I had try it, when I deploy it said that: Compilation from source: /app/design/frontend/{Vendor}/{theme_name}/web/css/source/lib/mage/gallery/gallery.less Compilation from source: frontend/{Vendor}/{theme_name}/en_US/css/source/lib/mage/gallery/gallery.less Unable to get content for 'frontend/{Vendor}/{theme_name}/en_US/css/source/lib/mage/gallery/module/_variables.less'
    – Mr Tim
    Commented Nov 28, 2016 at 9:31

In your custom config file for Grunt add path to gallery file: 'mage/gallery/gallery' along with 'css/styles-m' and 'css/styles-l'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.