WordPress.org

Make WordPress Core

Opened 8 months ago

Last modified 5 months ago

#48325 assigned enhancement

Additional filter in media-template.php. Let developers to hide attachment page link.

Reported by: limera1n Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Media Keywords: needs-patch
Focuses: ui Cc:

Description

Hi,

currently there is no easy way to hide "View attachment page" link from "media-modal" window. I think it would be great to add simple filter to disable this link and also add some HTML markups for "|" separators which can help users to use CSS selectors and style them. For example:

media-template.php, lines from 428

<div class="actions">
<?php
if ( ! apply_filters( 'disable_attachment_page_link', '' ) ) : ?>
<a class="view-attachment" href="{{ data.link }}"><?php _e( 'View attachment page' ); ?></a>
<span class="links-separator">|</span>
<?php endif; ?>

I think this feature is especially important when we don't want allow our users to access this type of pages.

https://i.imgur.com/C0AcLAG.png

Change History (2)

This ticket was mentioned in Slack in #core-media by joemcgill. View the logs.


5 months ago

#2 @joemcgill
5 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

Hi @limera1n,

Thanks for this report. I agree that this is not an easy thing to override at the moment. You would either need to override the whole template, or hide that link with CSS—neither a good option.

Allowing that template code to be filtered is one option for how to solve this, but I wonder if a better approach would be to update that template to check for the existence of a data.link value before printing the link so that this won't show up if the link value isn't available for any reason?

Note: See TracTickets for help on using tickets.