Attachment URL
Opened this issue · 3 comments
spacedmonkey commented
Currently the url pattern of /attachment/<:id> is supported. However attached uploaded to posts generate urls like this /<:year:>/<:month:>/<:slug:>/<attachment_slug> . This pattern doesn't have route and 404s
ryelle commented
All attachments (including uploads) should be redirecting to the /attachment/:id
page if loaded from the server (code), and attachment links in the JS-rendered content should also be caught by a JS click handler to generate and load the /attachment/:id
route (code).
Is one of these two not working for you? Can you share a link to a test site, or even just a screen recording, of it not working? Thanks!
spacedmonkey commented
spacedmonkey commented
Added the following to permalink file.
add_filter( 'attachment_link', array( $this, 'attachment_link' ), 10, 2 );
}
function attachment_link($link, $post_id) {
return home_url( '/attachment/' . $post_id );
}