I installed the module on a fresh Drupal 10.1.4 version and I add the field format on a image field under Article content type. When check the content created, I get into console log the fallowing error:
Uncaught TypeError: $(...).once is not a function
After inspecting I see that the file triggering this error is "drupal.imagefieldzoom.js" having the fallowing code:
$('.image-zoom-container img.original-image').each(function () {
$(this).once('init').parent('.image-zoom').zoom({
url: original_urls[$(this).attr('fid')],
on: drupalSettings.imageFieldZoom.image_zoom_style,
touch: drupalSettings.imageFieldZoom.image_touchscreen_compatible,
magnify: drupalSettings.imageFieldZoom.image_magnify,
duration: drupalSettings.imageFieldZoom.image_fade_duration
});
}
As far as I know due to this change record https://www.drupal.org/node/3158256 we need to remove jQuery dependency from the once feature in order to have this working.
Is there anyone working on this?
Thank you!
Comments
Comment #2
sarwan_verma commentedHi @ioana apetri,
I have fixed issue once function and also attached patch.
Please review and verify.
Comment #3
ioana apetri commentedQuick fix:
My image is now zoomed in and out with the fallowing code in the "drupal.imagefieldzoom.js" file.
Also I modified the dependencies library to be the fallowing:
- core/jquery
- core/drupal
- core/once
- core/drupalSettings
Comment #4
ioana apetri commentedI think also this part $(this).once('init') needs to be changed according the documentation.
Comment #5
sarwan_verma commentedThis is a updated patch.
Comment #6
ioana apetri commentedIn case JQuery is used, than we need to replase $ sign with JQuery word.If you want to use $ sign you have to use this:
(function ($, Drupal,once, drupalSettings) {
Comment #7
sarwan_verma commentedThis is a new updated patch.
Comment #8
nofue commentedThanks for the patch #7, @sarwan_verma, works for me.