---
title: "Force Thumbnail Links To Load In New Tab"
id: "176512"
type: "knowledgebase"
slug: "force-thumbnail-links-load-new-tab"
published_at: "2019-06-27T14:07:10+00:00"
modified_at: "2019-06-27T14:07:11+00:00"
url: "https://fooplugins.com/documentation/foogallery/developers/force-thumbnail-links-load-new-tab/"
markdown_url: "https://fooplugins.com/documentation/foogallery/developers/force-thumbnail-links-load-new-tab.md"
excerpt: "If you are using custom URL’s for your gallery thumbs, then you might also want to make those links open in a new tab. To add this functionality, simply add the following code snippet to your functions.php file: function foogallery_links_new_tab($attr,..."
taxonomy_knowledgebase_cat:
  - "FooGallery - Developers"
---

[FooGallery – Developers](https://fooplugins.com/documentation/foogallery/developers/)

# Force Thumbnail Links To Load In New Tab

## Related Articles

- [Change Gallery Output HTML](https://fooplugins.com/documentation/foogallery/developers/change-gallery-output-html/)
- [Override Image Captions](https://fooplugins.com/documentation/foogallery/developers/override-image-captions/)
- [Add NoFollow to Custom Links](https://fooplugins.com/documentation/foogallery/developers/add-nofollow-custom-links/)
- [Custom Hover Icons](https://fooplugins.com/documentation/foogallery/developers/custom-hover-icons/)
- [Add Class To All Gallery Thumbnail Links](https://fooplugins.com/documentation/foogallery/developers/add-class-gallery-thumbnail-links/)
- [Override Create Gallery Page Content](https://fooplugins.com/documentation/foogallery/developers/override-create-gallery-page-content/)
- [Display a Gallery in PHP code](https://fooplugins.com/documentation/foogallery/developers/display-a-gallery-in-php-code/)
- [FooGallery Developer 101](https://fooplugins.com/documentation/foogallery/developers/foogallery-developer-101/)
- [Developers](https://fooplugins.com/documentation/foogallery/developers/developers/)
- [Customize Your Gallery Using Custom CSS](https://fooplugins.com/documentation/foogallery/developers/customize-gallery-custom-css/)
- [Common FooGallery Custom CSS Customisation Tweaks](https://fooplugins.com/documentation/foogallery/developers/common-foogallery-custom-css/)
- [FooGallery Hooks](https://fooplugins.com/documentation/foogallery/developers/foogallery-hooks/)
- [Auto License Activations using wp-config.php](https://fooplugins.com/documentation/foogallery/developers/auto-license-activations-using-wp-config-php/)

**Need more help?** Browse all documentation or open a support ticket.

[All docs](/documentation/)

[Support](/support/)

If you are using custom URL’s for your gallery thumbs, then you might also want to make those links open in a new tab.

To add this functionality, simply add the following code snippet to your functions.php file:

```
function foogallery_links_new_tab($attr, $args, $foogallery_attachment) {
    $attr['target'] = '_blank';
    return $attr; 
}

add_filter( 'foogallery_attachment_html_link_attributes', 'foogallery_links_new_tab', 10, 3 );
```

Please note that you will need to set your gallery “Link To” setting to use custom URL’s:

[https://fooplugins.com/wp-content/uploads/2019/06/Link-to-1.png](https://fooplugins.com/wp-content/uploads/2019/06/Link-to-1.png)

Also please note that this will be applied to ALL galleries. If you want to limit this to a specific gallery, then you could check the ID of the global $current_foogallery;

Resources

## Find the right next step

Browse setup guides, get help with your site, or find licensing information.

![Image](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%200%200'%3E%3C/svg%3E)

### Documentation

Search setup guides, product docs, and troubleshooting articles.

[Browse docs](/documentation/)

![Image](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%200%200'%3E%3C/svg%3E)

### Support

Open a ticket with product details so we can help quickly.

[Get support](/support/)

![Image](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%200%200'%3E%3C/svg%3E)

### Licensing

Review account, renewal, refund, and license information.

[View details](/licensing/)
