You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, when restoring the image during destroy, it only considers the src attribute and not the data-safe-src. Since I'm using data-safe-src to store the original image source, this results in an empty src attribute after the gallery is destroyed.
The issue arises from how the resetImgSrc method only handles the src attribute, ignoring data-safe-src if it was used to store the original image. A fix would involve updating the method to also check for data-safe-src.
Here are the relevant parts of the code:
Code Storing the Image Source:
JustifiedGallery.prototype.extractImgSrcFromImage=function($image){varimageSrc=$image.data('safe-src');varimageSrcLoc='data-safe-src';if(typeofimageSrc==='undefined'){imageSrc=$image.attr('src');imageSrcLoc='src';}$image.data('jg.originalSrc',imageSrc);// stored for destroy method$image.data('jg.src',imageSrc);// changes over time$image.data('jg.originalSrcLoc',imageSrcLoc);// stored for destroy methodreturnimageSrc;};
When the gallery stores the original image source, it checks both
data-safe-src
andsrc
attributes:However, when restoring the image during
destroy
, it only considers thesrc
attribute and not thedata-safe-src
. Since I'm usingdata-safe-src
to store the original image source, this results in an emptysrc
attribute after the gallery is destroyed.Proposed Fix:
The issue arises from how the
resetImgSrc
method only handles thesrc
attribute, ignoringdata-safe-src
if it was used to store the original image. A fix would involve updating the method to also check fordata-safe-src
.Here are the relevant parts of the code:
Code Storing the Image Source:
Code Restoring the Image Source:
The
resetImgSrc
method should be updated to check and restore fromdata-safe-src
if that’s where the original image was stored.The text was updated successfully, but these errors were encountered: