Is there a way to make image attachment thumbnails open in a new tab?

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
Bruce Banner
Registered User
Posts: 1338
Joined: Thu Sep 25, 2014 10:36 am

Is there a way to make image attachment thumbnails open in a new tab?

Post by Bruce Banner »

Without need for an extension. Is there a line in the phpBB code I can simply change, or would something like this necessarily require an extension?
User avatar
axe70
Registered User
Posts: 752
Joined: Sun Nov 17, 2002 10:55 am
Location: Italy
Name: Alessio
Contact:

Re: Is there a way to make image attachment thumbnails open in a new tab?

Post by axe70 »

Yes, jQuery (that can be pure js) example:

HTML into overall_footer.html
https://github.com/axew3/phpBB-image-at ... er.html#L3

Code: Select all

<div id="w3rPopup" class="w3rPopupContainer text-center inputbox" style="display:none">
<table class="w3wrapTABC">
<tr><td class="w3wrapTDC">
<div class="w3divContainer">
<div class="w3divCont"><strong>{{ lang('W3POPUP_TEXTEXPLAIN') }}</strong></div>
<div class="w3divimg"><img id="w3-img-rotate" src="" onclick="w3rotateByDeg(this);" /></div>
<div class="w3divCont"><button class="w3divCont button" type="submit" id="w3btn" onclick="w3sendThis(document.getElementById('w3-img-rotate'));">{{ lang('W3POPUP_BUTTONTEXT') }}</button></div>
</div>
</td></tr></table>
</div>
so after, JS code into same overall_footer.html
https://github.com/axew3/phpBB-image-at ... .html#L317

Code: Select all

  $( ".w3rotate" ).on( "click", function(e) {
    e.preventDefault(e);
    e.stopPropagation(e);
   $("#w3rPopup").css({ "display":"block","position":"fixed","top":"0px","right":"0px","bottom":"0px","left":"0px","margin":"auto","z-index":"99999" });

   var remListenerRIcont = $(document).mouseup(function (e) {
     if ($(e.target).closest(".w3rPopupContainer").length === 0) {

      $("#w3rPopup").css("display", "none");
      $("#w3-img-rotate").removeAttr("style");
}
    });
  });
the necessary code is very short but it depend on what you finally want to achieve with the complete result,
if not complicate for you, into the linked snippet you'll find all the necessary
Do not take me too serious
Anyway i do not like Discourse
User avatar
Mannix_
Registered User
Posts: 1838
Joined: Sun Oct 25, 2015 2:56 pm
Name: Matt
Contact:

Re: Is there a way to make image attachment thumbnails open in a new tab?

Post by Mannix_ »

this js should do the trick

Code: Select all

const thumbnails = document.querySelectorAll('.thumbnail a');
thumbnails.forEach((thumbnail) => {
    thumbnail.setAttribute("target", "_blank");
})
Did I helped You? Consider a donation.
New version of phpBB has been released? My styles aren't validated for it yet? Check my page for the latest downloads!
User avatar
axe70
Registered User
Posts: 752
Joined: Sun Nov 17, 2002 10:55 am
Location: Italy
Name: Alessio
Contact:

Re: Is there a way to make image attachment thumbnails open in a new tab?

Post by axe70 »

Mannix_ wrote: Wed Oct 05, 2022 8:53 am this js should do the trick

Code: Select all

const thumbnails = document.querySelectorAll('.thumbnail a');
thumbnails.forEach((thumbnail) => {
    thumbnail.setAttribute("target", "_blank");
})
the gift of simplicity!
Do not take me too serious
Anyway i do not like Discourse
Post Reply

Return to “phpBB Custom Coding”