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.
Problem
The attribute rel is used to group links in a gallery. It is done allways, even with special rel values like "nofollow".
Proposed resolution
Check that rel attribute value is not a well known value intended for a specific use.
In colorbox_node.js ($.fn.colorboxNodeGroup, about line 100) could be done with something like this:
var rel = $(this).attr('rel');
var knownRels=new Array('alternate', 'author', 'bookmark', 'help', 'license', 'next', 'nofollow', 'noreferrer', 'prefetch', 'prev', 'search', 'tag');
if ($('a[rel="' + rel + '"]:not("#colorbox a[rel="' + rel + '"]")').length > 1 && $.inArray(rel, knownRels)==-1) {
Comment | File | Size | Author |
---|---|---|---|
#15 | colorbox_node-better-gallery-implementation-2120319-15.patch | 3.84 KB | Andre-B |
#11 | colorbox_module-rel_nofollow-2120319-11.patch | 862 bytes | Andre-B |
#10 | colorbox_module-rel_nofollow-2120319-10.patch | 855 bytes | Andre-B |
#3 | colorbox_module-rel_nofollow-2120319-3.patch | 2.31 KB | miguel.svq |
Comments
Comment #1
iLLin CreditAttribution: iLLin commentedI would like it more if this was an admin setting instead of hard coded so the user can add w/e they want. We can start with defaults but it would be better if it was editable.
Comment #2
miguel.svq CreditAttribution: miguel.svq commentedI do agree.
Maybe better this in .js (L 119):
if ($('a[rel="' + rel + '"]:not("#colorbox a[rel="' + rel + '"]")').length > 1 && $.inArray(rel, Drupal.settings['colorbox_node']['known_rels'] )==-1 ) {
In .module, (L 17):
...and in colorbox_node_form_alter (about L 55)
Comment #3
miguel.svq CreditAttribution: miguel.svq commentedI'm unsure about the patch format and naming, hope it's right.
Comment #4
iLLin CreditAttribution: iLLin commentedK, I will work this in when I get a chance. Thanks!
Comment #5
Andre-BI have additional issues with the gallery function in the latest "stable" colorbox version:
for no reason I get a gallery feature for a colorbox link, that does not contain any
rel=""
, I am not even sure where and how it get's the counts displayed in the captions:update:
additional entries came from admin menu, seems like a "huge" bug here:
colorbox_node.js (l101):
Comment #6
Andre-BComment #7
Andre-BComment #8
Andre-BComment #9
Andre-Bbad patch. see next comment
Comment #10
Andre-Blast patch contained stuff from something else. check this
Comment #11
Andre-Bsorry for the spam, just ran into another issue which is fixed by this updated patch as well:
currently every colorbox-node links are turned into galleries, even if rel is not set.
Comment #12
iLLin CreditAttribution: iLLin commentedHave u checked with DEV? I believe this issue is fixed in DEV. Let me know if it's not.
Comment #13
Andre-Bissue is not fixed completly in dev. My patch added two things: check for if($(this).attr('rel')) and changed the jquery selector from
$('a[rel="' + rel + '"]:not("#colorbox a[rel="' + rel + '"]")')
to$('a.colorbox-node[rel="' + rel + '"]:not("#colorbox a[rel="' + rel + '"]")')
as well as the followed $related. there are multiple issues right now to be fixed. do you want to apply them manually or shall I create a new issue + patch for latest dev? I also believe that we should not add a whitelist for rel's, but add another css class to indicate wether that link belongs to a grouping or not. What do you think?
Comment #14
iLLin CreditAttribution: iLLin commentedHmm that's a good idea. How about a complete patch against DEV. Sounds like it's all related.
Comment #15
Andre-B[PATCH] better gallery implementation:
- fixed selectors to only match colorbox-node-gallery links for related items.
- added a class to handle colorbox gallery definition: colorbox-node-gallery;
in order to create a gallery you now have to define a link like this:
<a href="#" class="colorbox-node colorbox-node-gallery" rel="gallery1">Image</a>
- excluded duplicate anchors from showing up as a single item in the gallery:
-> this will create a gallery of
two items only, instead of three with 2 multiple targets.
this is very handy if you create listings in view that might have multiple fields + links to the same node. With his implementation the gallery will still work as expected instead of forcing you to alter the complete markup to only include one link.
patch created with git format-patch.
Comment #16
aze2010 CreditAttribution: aze2010 commentedThank you!
#15 Patch is working so far!!
Comment #17
Andre-Bpatch is waiting for commit for almost a month, any blockers here?
Comment #18
iLLin CreditAttribution: iLLin commentedWaiting for more testers...
Comment #19
jncrucesThe patch #15 not worked for me.
Colorbox 7.x-2.4
Colorbox Node 7.x-3.2
Colorbox library 1.4.18
Comment #20
iLLin CreditAttribution: iLLin commentedI'm just getting back to this and have started testing the patch locally. I have noticed that if you have a rel and you don't have the colorbox-node-gallery class, it still tries to add the pager. Then if you click next, nothing works. @Andre-B, do you experience this as well?
Comment #21
iLLin CreditAttribution: iLLin commentedIm going to update DEV with this patch and a few other lingering things. @Andre-B I added one other check to this to remove the rel attribute but I don't like it as it changed the HTML markup. I think we should clone the link thats sent to the colorbox function without passing in the original to prevent that, matter of fact let me just do that, give me a sec and I will get this updated to DEV and then you can review.
Comment #22
iLLin CreditAttribution: iLLin commentedCommitted: http://drupalcode.org/project/colorbox_node.git/commit/4b3f725
Thanks Andre-B for your work!