-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Bug: Author role can't add a featured image uploaded by someone else #18510
Comments
I can confirm that this bug exists in the last version of the Gutenberg plugin (6.9). |
Related Core Trac Ticket - https://core.trac.wordpress.org/ticket/47291 |
Is the bug about setting the featured image in the data? Or is it about rendering the featured image once it's set? The code responsible for fetching the image for rendering is here:
|
Having dug a little deeper, So I would suggest writing a test that compares fetching an attachment of another author in the edit context, and the non-edit context, from a user with the author role. If the test passes then the issue is likely with Gutenberg. If it fails, then the issue is probably in WP Core in the REST API. |
For me, this does not only happen with the featured image, but for any image that is requested through the media endpoint in the REST API by an author, if the image was uploaded by another user. For now, I worked around this by allowing all users with a role of add_filter( 'register_post_type_args', function( $args, $post_type ) {
if ( 'attachment' !== $post_type ) {
return $args;
}
$args['capabilities']['edit_others_posts'] = 'upload_files';
return $args;
}, 10, 2 ); |
@gchtr Thanks for this. The approach is useful for smaller platforms, but not for sites with many users, as it essentially gives them the capability to edit any image! @gziolo Are there any plans on fixing this bug? It is severe given that it is currently affecting all multi-author sites. What better reason do we need to prioritize this? =) |
@anthonyburchell or @getsource – is this bug on your radar? I don't have enough expertise to judge myself how important this fix would be. I only know that I was able to reproduce it a few months ago. |
@anthonyburchell and @getsource - did you have a chance to look into this? Thank you. |
@anthonyburchell or @getsource or @gziolo |
I do have the same problem on my site. |
#22847 also discusses this. |
The bug is still present. I have a custom user role with Is there any workaround? |
@vyskoczilova please try this one:
|
@meloniq Thanks a lot! It works but it brings a new issue:
And I've spotted a kind of related capability issue with REST API:
I've created a screencast here: https://www.loom.com/share/93247e66ba72474ca0db78612f9f565f where you can see both issues. |
Wow, this seems like a severe bug to me to stay uncorrected for a year and a half. It's such a basic feature and a common action (for authors to use already-uploaded images as a featured one) that I wonder why so few people manifested here. |
It's bigger than that unfortunately. All images that are not uploaded by the author themselves will fail. For example, using an author account, try inserting an image you did not upload yourself. And then click on it. You will see that some block settings are missing, like image sizes. This is because it is failing to fetch the image. I have been trying to push this to the higher ups at WordPress and no one seems to understand or care for it. Please help spread the word. |
I believe this is not a block editor issue but a REST API issue, and that the trac ticket was incorrectly closed by @garretthyder due to the misunderstanding of the nature of the bug. I would also note that issues like this stay like this unless somebody champions them. Long standing tickets that haven't been fixed in a long time stay unfixed unless you bring them to attention. SImply bumping them with a comment is the most inefficient method of doing this as it only pokes those people who are subscribed to the issue, it'll get lost in the noise. Raise it in the weekly meeting agendas instead. Also a test case demonstrating it is, or is not a REST API bug |
Created PR that should fix this issue #33567. |
I've still this kind of error. I've added the GET Is my bug related to this one? |
@reneroboter, to avoid 403 errors for users with low permissions, the |
In the block editor screen, on the right-side where we have the featured image panel, if a user is an author and can 'upload_files', the featured image that is not their own image will not load up when selected. This bug is only present when user selects an image uploaded by someone else.
Reproduce:
Works fine with images uploaded by the user themselves.
Tested on WP 5.3 and several environments.
Probable cause of this bug:
The Block Editor uses RESTful API to facilitate its functionality and the endpoint that is responsible for media attachments, for some unthoughtful reasons, checks if the current author is allowed to update the image that is about to be used as Features Image.
Maybe this part is the gremlin:
Not sure.
An obvious fix would be to add
edit_others_posts
to author roles, but that defeats the main idea of the author role.This is clearly a severe bug. Please let me know if you have questions to reproduce this bug.
The text was updated successfully, but these errors were encountered: