#53928 closed defect (bug) (invalid)
Media Attachment Pages Break (404) when Elementor is Activated
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Media | Keywords: | |
Focuses: | Cc: |
Description
Strange problem began about mid-June.
When Elementor plugin is activated, all Media Attachment pages for *unattached* media return a 404 error; Media Attachment pages for attached media are unaffected.
This problem occurs when Permalinks are set to 'Post name', but the problem goes away when Permalinks are set to 'Plain'. Other Permalink settings have not yet been tested.
This problem affects sites with Media uploading settings set to use 'month- and year-based folders' as well as sites that do not use month- and year-based folders.
Deactivating Elementor fixes the problem; all Media Attachment pages work (200).
This issue has affected and been replicated on 4 different sites that use Elementor.
Testing has only been done on SiteGround servers with all other plugins deactivated and the Twenty Twenty-one theme activated.
Elementor support claims they cannot reproduce this issue on their own test environment.
Change History (4)
#1
follow-up:
↓ 2
@
2 years ago
- Keywords reporter-feedback added
- Severity changed from major to normal
- Version 5.8 deleted
#2
in reply to:
↑ 1
@
2 years ago
Are you able to check if this started happening in WordPress 5.7?
I am not really sure when this began happening, but I did roll back WP to 5.5.5 and Elementor to v 3.2.5 and the issue persisted for all unattached media *except* when Permalinks were set to 'Plain'
In the commit [50132] some changes were made to
get_attachment_link()
to prevent WordPress returning links that would 404 for attachments in some circumstances, for full details see ticket #52373.
This could have something to do with it, but I am not sure.
As the bug is only apparent with a plugin installed, it's possible the issue is caused by the plugin but it would be good to confirm the change in WordPress wasn't a contributing factor.
Definitely is related to Elementor as I did a fresh test install, see below... But again, their support claims they cannot replicate the issue. I am bringing it up here in the event someone can identify what possible changes in core could be causing this relative to Elementor.
As this is only happening with a plugin enabled, I've reduced the severity of the issue. I've also removed the version as it's used to indicate when the bug was introduced and it's unlikely to be 5.8 as that wasn't released until late July.
Yes, this most likely began sometime in June/July during WP 5.7.x
To rule out previously installed plugins and themes from testing, I created a fresh testing environment:
1) WP 5.8
2) 2021 Theme
3) No add'l plugins installed
4) Permalinks setting: Post Name
5) Create New Post: Test @ /test and add inline image tahoe.webp
6) MA page for tahoe.webp works @ /test/tahoe/
7) Create 2nd Post: Test @ /test-2 and add inline image coins-512.png
8) MA page for coins-512.png works @ /test-2/coins-512/
9) Permanently delete /test-2
10) In Media Library, URL for coins-512.png is now changed to /coins-512/
11) MA page for coins-512.png still works but now is @ /coins-512/
12) Install Elementor v 3.4.0
13) Refresh MA page /coins-512/ and now a 404 error is generated!
14) Refresh MA page /test/tahoe/ and this MA page still works (is still attached to /test)
15) Set Permalinks to 'Plain'
16) Refresh Media Library
17) URL to MA page for coins-512.png has now changed to /?attachment_id=9
18) The MA page at /?attachment_id=9 is now visible again
19) Deactivate Elementor
20) Refresh page @ /?attachment_id=9 and it is still visible at the new URL
21) MA page for tahoe.webp has been changed to /?attachment_id=6 and is also visible
So the issue involves changes that occur to the URL of Media Attachment pages when they are detached from a post either manually or as a result of the permanent deletion of a post *when* Elementor is installed and *when* permalinks are set to anything other than 'Plain'. Plain eliminates this problem I think due to the query component present in the URL of the MA page.
This is why I believe WP core has something to do with it.
Hopefully others are able to replicate this issue and test further.
Ideally, Media Attachment page URLs should be created once and never change since the change leads to a 404.
#3
@
2 years ago
- Keywords reporter-feedback removed
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
Thanks for the additional information.
I've tested this each major release of WordPress since 5.4 and with the latest version of Elementor the file not found error for unattached images happens in each version of WP.
I think your issue is plugin rather than WordPress related.
As such, I am going to close this ticket off as invalid. In this case, that's trac's really unfriendly term for the problem is likely to be happening in other software. Feel free to post any follow up comments on this ticket, I'll still get notified even with the ticket closed.
Testing notes:
Starting point for each test is:
1) Permalinks set to %postname
2) Plugins enabled: query-monitor, elementor
3) PHP version: 7.4
Uploading directly to media library
1) Go to WP Admin > Media Library
2) Upload an image: Image from iOS.jpg
3) Click image, attachment page is /image-from-ios/
4) Visit /image-from-ios
receive 404 error
5) Disable plugin
6) Reload /image-from-ios
and page shows as expected
Uploading via post
1) Go to WP Admin > Posts > Edit Hello World
2) Create an image block
3) Upload image to image block: Image from iOS.jpg
4) Go to media library
5) Click image, attachment page is /hello-world/image-from-ios/
6) Visit /hello-world/image-from-ios/
, image shows as expected
7) Delete Hello World Post
8) Go to media library
9) Click image, attachment page is /?attachment_id=5
10) Visit /?attachment_id=5
, 404 error
11) Disable plugin
12) Visit /?attachment_id=5
, image shows as expected
As the file not found errors were occurring back to WP 5.4 (well before the last set of changes to the permalink function), I think it's something in the plugin but I am not sure what. I see it does filter media permalinks.
Ideally, Media Attachment page URLs should be created once and never change since the change leads to a 404.
In most cases the URLs remain unchanged but for media uploaded to a post the URL is /post-slug/media-file-slug
. If the post is subsequently trashed or deleted then the media URL changes as /post-slug/
no longer exists for the media to live under.
#52373 is about what to do with attachment URLs when the post is deleted, feel free to add some thoughts there.
Hello and thanks for your report.
Are you able to check if this started happening in WordPress 5.7?
In the commit [50132] some changes were made to
get_attachment_link()
to prevent WordPress returning links that would 404 for attachments in some circumstances, for full details see ticket #52373.As the bug is only apparent with a plugin installed, it's possible the issue is caused by the plugin but it would be good to confirm the change in WordPress wasn't a contributing factor.
As this is only happening with a plugin enabled, I've reduced the severity of the issue. I've also removed the version as it's used to indicate when the bug was introduced and it's unlikely to be 5.8 as that wasn't released until late July.