Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Origin: unattached uploads get redirected to /wp-admin #20

Open
skyminds opened this issue Jan 26, 2020 · 1 comment
Open

Origin: unattached uploads get redirected to /wp-admin #20

skyminds opened this issue Jan 26, 2020 · 1 comment

Comments

@skyminds
Copy link

Describe the bug
Hi,

When Origin is enabled, uploads that are not attached to a post/page get redirected to /wp-admin, instead of displaying the current attachment.

To Reproduce
Steps to reproduce the behavior:

  1. Activate Origin
  2. curl -I [attachment_page]
  3. Results:

HTTP/2 301
date: Sun, 26 Jan 2020 22:28:35 GMT
content-type: text/html; charset=UTF-8
set-cookie: __cfduid=d1728297f51b5477515a75e7f87906d451580077715; expires=Tue, 25-Feb-20 22:28:35 GMT; path=/; domain=.example.com; HttpOnly; SameSite=Lax; Secure
expires: Sun, 26 Jan 2020 23:28:06 GMT
cache-control: max-age=3600
x-redirect-by: WordPress
location: https://www.example.com/wp-admin/

  1. See error

Expected behavior
The attachment page should redirect to the attachment itself.

Thank you,
Matt

@sybrew
Copy link
Owner

sybrew commented Jan 28, 2020

Hi Matt,

I'm afraid I couldn't reproduce this issue myself. So, I believe there's another plugin interfering and rewriting the URLs on a low level. Most likely, an image-optimization, security, or CDN tool.

Given your expertise using the CLI, I don't think you'll have trouble browsing through the active plugins' and theme's code.

I recommend you look for the plugin or theme that hooks into this filter: wp_get_attachment_url.
Alternatively, look for filters get_the_guid, upload_dir, *_option_upload_path (* is a wildcard), or get___wp_attached_file_metadata—might they be altered.

See if deactivating the resulting plugin or theme helps pinpoint the core of the issue. Please let me know which it is—might anything come up. Thank you!

This is the active code in Cord affected by this issue, where $post is the current attachment:

$url = \wp_get_attachment_url( $post->ID );
if ( $url ) {
\wp_safe_redirect( $url, 301 );
exit;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants