It turns out this is easily solved by creating a file attachment.php
and redirecting to the file itself.
- Create an attachment.php file in your WordPress theme folder
-
Put this code in the file
<?php wp_redirect(wp_get_attachment_url(), 301); ?>
-
Upload it and there you go
This link explains in full.
Related Posts:
- Add a menu item to WordPress 3.5 Media Manager
- For what security reasons are svgs blocked in the media uploader?
- Update media library files after upload via FTP
- How can you set maximum width for original images?
- Custom post type with a forced fixed aspect ratio image crop
- Media library to list images only user uploaded
- Proper way to add a button to the top menu of the media library?
- Filter for changing MediaElement.js Settings
- display image size in media library screen
- What is the best practice for renaming WordPress media files?
- wp media regenerate unknown –image_size parameter
- Changing the media library default tab
- WordPress Uploads Folder can’t be Written to
- Best plugin to manage media library? [closed]
- Best image hosting service
- Is it possible to generate JPEG progressive thumbnails?
- How to set additional parameter in wp.media?
- Way to display media library in frontend
- Images are registered in media library but still won’t show up
- Run script after clicking Set Featured Image in Media
- Uploading non-media files?
- How do I control video media display sizing with native wordpress player
- Media > Image Sizes aren’t being applied to uploads
- Rest API rename media
- Disable drag and upload in Media Library
- Custom media picker in meta box: how to select available image sizes?
- Add media column to edit post screen
- Can’t edit media details in new role
- add_image_size landscape or portrait
- What table is the media’s sort order stored?
- Add custom tab on the media manager
- Moving existing media items to new upload path structure not updating full URL path
- How to limit characters of the post title?
- How to bulk Edit Dates in Media Library?
- Trigger JS in custom meta box if a featured image is loaded/exists
- WordPress Built In Dialog Box For My Plugin
- Deleting images from gallery remain as attachment
- Cannot embed YouTube videos “Failed to embed” error
- wp_get_attachment_image_src() returns wrong url
- Create Media via REST API from Android Application
- How to upload media to a specific folder without a plugin in WordPress?
- How to extend an existing (Gutenberg) block
- Custom icons in media library
- Overwrite media matching post title using WP CLI’s media import command
- Password Protecting Media
- Creating subfolders in the media library
- WordPress media upload automatic refresh
- Can I Change the Media Upload Location for each user?
- Media Library empty after server move (exact copy of files and db’s)
- media library not showing thumbnails after deleting full image
- Media attachment pages giving 404’s
- Extending wp.media.model, query media from different blog on network and refresh view
- Media changes not updating posts
- Use rich text editor in ‘Edit Media’, for attachment media description
- How to disable Media Library?
- Theme loosing some images when moving to new server
- Adding .mov files (not from YouTube) [duplicate]
- Woocommerce blank screen variable product attribute image thumbnail
- formatting horizontal and vertical images in Settings?
- How to get a list of all attachements urls for every post of a wordpress installation?
- Access generated thumbnails
- Media permalink to go directly to uploaded PDF, instead of a media page with a link
- WXR file – Media import failed – how to force import?
- Get all uploaded images using REST api
- WordPress REST API to get all media not working
- Disable Responsive Image Sizes crop
- Adding Files to Page Only Adds Title, Doesn’t Create Link
- Deleting media using the WordPress Rest API
- When inserting an image in a post, how to link the image to a resized URL instead of the full image URL?
- Images missing from the media folder
- How to Protect Uploads, if User is not Logged In?
- Is There A Way To Auto-Stock Media Files To Every Site On A WordPress Network?
- Direct media library upload saving in wrong month date folder in custom theme
- Showing added mime types in REST media response
- Replace Swedish characters in filenames
- How to resize image in wordpress from backend? Seems like bug in wordpress
- Gifs displaying soft?
- WP Cli + xargs fails
- Hide download button from audio player
- Insert Media – Attachment – Link to : Remove options
- Import media in bulk with caption and titles?
- Only current gallery images with get_attached_media
- wp media popup close all popup
- Add hyperlinks in media description
- ACF Gallery & mqTranslate, Title and Description not displaying in other languages
- Can somebody explain this mediaelement and audio tags
- Custom image sizes
- WordPress / Audio player
- Unable to send upload url
- WP Feed namespace attr issue
- Another “Sent Headers” Error w/ Missing Temporary Folder
- Pictures won’t display in media library and also won’t show preview when selected
- How to import and update images/galleries that point to an old site
- Media Library empty after server migration
- When I upload any media file it says “The uploaded file could not be moved to wp-content/uploads/2017/04”
- Using WordPress.com API to retrieve featured images
- Help with WordPress slider
- How to batch-add image file extension without losing DB refs?
- How to add a column showing real media usage (count) to the media list view?
- Looking for a way to insert PDF image preview in TinyMCE