Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
is it possible to build a field in the UI, where a link to a CDN could be inserted, from where the colorbox library is fetched? This field could be prefilled as a fallback if the library isn't downloaded to /libraries directory.
Comment | File | Size | Author |
---|---|---|---|
#6 | js_library_changes-2893750-6.patch | 6.65 KB | Anonymous (not verified) |
Comments
Comment #2
renatogComment #3
renatogHi Eric how are you?
At this time not exists this feature, but is really interesting. If you need can report a Feature Request with it for us.
If you can send us a patch.
If you can't create patch, just create a Feature Request with your idea. It will help a lot and us work for create.
Thank you very much Eric.
Good Work.
Regards.
Comment #4
Eric HeydrichHi Renato,
I tried something, but can't achieve to provide the CDN-Link through the UI. So I done something different:
1. I added a checkbox and configuration in colorbox settings for choosing between CDN or Local Files
2. I added a library colorbox-cdn to colorbox.libraries.yml, which points to the CDN URL
3. I added a condition to ColorboxAttachment.php which checks if CDN source is chosen and to provide library from colorbox-cdn or colorbox or colorbox-dev
4. I added default config library_source: 0 in config/install/colorbox.settings.yml to always provide CDN link as default after installation
5. I changed the Error message on Status Report (maybe this could then be just a warning)
ColorboxSettingsForm.php
in buildForm()-function
in submitForm()-function
ColorboxAttachment.php
in attach()-function
colorbox.libraries.yml
config/install/colorbox.settings.yml
colorbox.install
Would like to hear your opinion about the changes.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous at Cheeky Monkey Media commentedComment #6
Anonymous (not verified) CreditAttribution: Anonymous at Cheeky Monkey Media commentedThanks for the suggestions Eric.
I added the Library Source setting in Advanced Settings.
However I ended up using a slightly different implementation of the library, cleaning some things up to not have different library definions based on settings, but just alter the js source based on the options, allowing other modules to include colorbox/colorbox and have the module's settings still applied.
Comment #7
Neslee Canil Pinto