hooks – How can I remove the ‘File URL’ field from the image attachment editor?


When you go into the Media Library and select an image to edit, its associated ‘Attachment details’ page appears. On this page, there is a ‘File URL’ field which details the attachment file’s URL.

This field is created, using the following HTML Markup:

<span class="setting" data-setting="url">
    <label for="attachment-details-two-column-copy-link" class="name">File URL:</label>
        <input type="text" class="attachment-details-copy-link" id="attachment-details-two-column-copy-link" value="https://example.com/wp-content/uploads/2020/08/image-file-name.jpg" readonly="">
    <span class="copy-to-clipboard-container">
        <button type="button" class="button button-small copy-attachment-url" data-clipboard-target="#attachment-details-two-column-copy-link">Copy URL</button>
        <span class="success hidden" aria-hidden="true">Copied!</span>
    </span>
</span>

Ideally, I would like to be able to simply insert some kind of remove_action function into the theme’s functions.php file.