We can extend the core js in below way
Create a requirejs-config.js in MYMODULE/view/frontend
var config = {
config: {
mixins: {
'mage/gallery/gallery': {
'NAMESPACE_MYMODULE/js/gallery_brand_logo': true
}
}
}
};
Then create gallery_brand_logo.js in
code\NAMESPACE\MYMODULE\view\frontend\web\js\gallery_brand_logo.js
define(['jquery','mage/utils/wrapper'], function ($, wrapper) {
'use strict';
return function (initialize) {
return wrapper.wrap(initialize, function (initialize, config, element) {
// my code before
initialize(config, element);
// my code after
//brand log
if(config.brandlog){
$('.fotorama__nav-wrap').css('display', 'block');
$('.fotorama__nav-wrap').addClass('fotorama__nav-wrap--vertical');
$('.fotorama__nav').before('<div style="border: 1px solid red;color: red;height: 70px;" class="brandlog"><img src="'+config.brandlog+'" /></div>');
}
//brand log end
});
};
});
Note :- In above I used custom option brandlog, pass this value in product/view/gallery.phtml so i extend product/view/gallery.phtml also and
<script type="text/x-magento-init">
{
"[data-gallery-role=gallery-placeholder]": {
"mage/gallery/gallery": {
"brandlog": "<?php /* @escapeNotVerified */ echo $logopath; ?>",
.
.
.