Plugin Author
nK
(@nko)
Hi.
Show me an online example of your implementation. Your custom script parts also will be helpful. Then I can try to help.
Regards, nK.
Thread Starter
Antoine
(@ant1busted)
Plugin Author
nK
(@nko)
Hi.
The images use srcset attribute, so you also need to change it. This example should work:
jQuery(function($) {
$(document).on('mouseover', '.vp-portfolio__item-img img', function() {
var $this = $(this);
// save old image.
$this.attr({
'data-saved-src': $this.attr('src'),
'data-saved-srcset': $this.attr('srcset'),
});
// add gif.
$this.attr({
src: 'https://www.studio-oracle.fr/wp-content/uploads/2018/11/ESCAPE-TIME_1.gif',
srcset: '',
});
});
$(document).on('mouseout', '.vp-portfolio__item-img img', function() {
var $this = $(this);
// restore image.
if ( $this.attr('data-saved-src') ) {
$this.attr({
src: $this.attr('data-saved-src'),
srcset: $this.attr('data-saved-srcset'),
});
$this.removeAttr('data-saved-src');
$this.removeAttr('data-saved-srcset');
}
});
});
-
This reply was modified 7 years, 2 months ago by
nK.
Thread Starter
Antoine
(@ant1busted)
It works, thanks. Do you think I could customize the template of visual portfolio to use an ACF field that contains the gif image? Can I just override the portfolio template to add a data attribute to the image tag?