• Resolved ZeroGravity

    (@zerogravity)


    I have created a custom gallery page for each gallery on the website. In the album I have each gallery set to open a custom URL and have it set to the custom gallery page. I left the custom target as default.

    This morning the galleries started opening in a new tab whereas previously they would open in the same tab. I want them to open in the same tab. I don’t know what happened or changed. There are about 20 galleries so going through and changing the target for each gallery is going to be laborious.

    Looking at the code target=”default” is added to the link.

    I tried the code below and it isn’t working. The code still shows target=”default”. Is there a reason why this may have suddenly changed?

    EDIT: Using devtools I removed the target attribute from the link and it opens in the same tab.

    add_filter('foogallery_attachment_html_link_attributes', 'foogallery_override_target', 10, 3);
    function foogallery_override_target( $attr, $args, $foogallery_attachment ) {
    	$attr['target'] = '_self';
    	return $attr;
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author bradvin

    (@bradvin)

    hi @zerogravity

    This code has not been updated in a while, and definitely should not have changed overnight. The only thing I can think of is that your browser has updated and the handling of the target=”default” is now handled more strictly.

    target=”default” is actually wrong, and the correct value should be _self.

    Please update the target for each gallery to be _self to see if that corrects the issue.

    Thread Starter ZeroGravity

    (@zerogravity)

    Hi @bradvin,

    Thanks for the quick reply!! I am baffled as well why this started happening but it is across all browsers I have tested, not just one. As mentioned I have about 20 galleries so it will be a pain to go through and change every one and I want to make sure it is foolproof in case a user adds another gallery.

    I don’t believe target=”default” is valid HTML. I’ve looked at many resources and it isn’t mentioned on any of them. If anything target=”default” should open in the same tab as the default for the target attribute is “_self”. Not sure how the browsers handle and invalid value.

    I would have assumed that leaving the custom target setting as default wouldn’t have saved anything to the database and as a result not output the target attribute, leaving everything to be handled by default for the browser. I deleted a couple of the “custom_target” rows from postmeta table and the code outputs target=”_self”.

    It might be nice if there was a setting under FooGallery -> Settings -> Albums that would define what the default should be. Especially as target=”default” doesn’t seem to be valid HTTML.

    I tracked down another filter that solves the problem but outputs target=”” instead of target=”_self”. I’m not sure if I am using it correctly.

    add_filter('foogallery_album_build_gallery_link_target', 'zgwd_fg_override_album_target', 10, 1);
    function foogallery_override_target( $target ) {
    	if ( $target == "default" )
    		$target = "_self";
    
    	return $target;
    }

    Thanks again for your quick reply! I love your gallery plugin! I would like to see the “custom target” setting handled a little differently. ??

    phillcoxon

    (@phillcoxon)

    Hi @zerogravity,

    Just confirming we are going to release a fix for this in our next update to insure target is set to “_self” moving forward.

    Thread Starter ZeroGravity

    (@zerogravity)

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Album is opening galleries in new tab’ is closed to new replies.