Opened 13 years ago
Last modified 13 months ago
#20602 reopened enhancement
Replace media
Reported by: | PorridgeBear | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.3.1 |
Component: | Media | Keywords: | |
Focuses: | Cc: |
Description
I have been developing themes for clients lately that require the same image across the theme in varying places. A good example is an event site where the image is a badge/sticker showing the price of the tickets. This gets output on various pages in varying locations.
get_attachment_link is perfect as I can plugin a single ID and use the graphic wherever. However, the ticket prices change as the event gets closer and the graphic needs to be updated which breaks the theme in production when my client does so as a new ID is generated.
This doesn't make too much sense to me. I've worked with and developed CMSs of all kinds and usually the ID is preserved.
I would at least like the option, perhaps a checkbox, to indicate I want to reupload a new image. I think it's more common that an update on a media item would be to modify the same logical graphic rather than just replacing it with something entirely new.
I found the following plugin but I feel this really ought to be core.
http://wordpress.org/extend/plugins/enable-media-replace/
Thanks for your consideration.
Change History (27)
#2
@
13 years ago
Oh, we already have an image editor. If this is already handled there somehow, then my points above are moot.
#3
@
13 years ago
This particular plugin offers 2 scenarios:
Just replace the file
Note: This option requires you to upload a file of the same type (image/png) as the one you are replacing. The name of the attachment will stay the same (earlybird.png) no matter what the file you upload is called.
Replace the file, use new file name and update all links
Note: If you check this option, the name and type of the file you are about to upload will replace the old file. All links pointing to the current file (earlybird.png) will be updated to point to the new file name.
In my case I only want to Just replace the file most of the time. But it's nice that I get an option to switch the file type and so on too. In this use-case that led me to raise this issue it's this need to just swap in an updated image (it has no thumb sizes) but I appreciate you would want to re-run the thumb sizes if present.
As regards the CDN/external services and non-triviality, I don't think they should be the guiding principle. Site owners not being able to update images on their site without breaking the theme seems far worse.
My client's inclination in all cases has been to just update the image in Media. It has broken so many site images. I don't want to have my clients come to me every time they want to update a price image or some other centralized image.
#4
@
13 years ago
This sounds like plugin material. Generally the attachment post is a part of the uploaded image. It's used to display the image on the front-end, to store additional information about it, EXIF, caption, description, sizes, etc. So the content here is not the attachment post, it's the image.
Uploading another image and reusing the same attachment just to keep the post_ID doesn't seem right. You will also have to replace all the information about that image.
For the particular user case it seems better to let the user specify which image (and attachment post) to use instead of hard-coding it in the theme.
#5
follow-up:
↓ 11
@
13 years ago
If we can get away from either how hard it is, or the internal structures of an attachment and how it links to posts and so fourth, the basic use-case is sound.
You can't have in asset management/media management, a situation where the user uploads an asset and suddenly it becomes an entirely different asset. It just doesn't align with any other asset/CMS system I have used, and it causes problems.
You don't change the ID of a post when you update it, so why would you update the media ID when it's updated?
The use-case is using the WP media library to store assets independent of posts (images, PDFs and so on) that can be linked into the theme where required and the user can then update these centrally. I think this is really useful.
In any event, the plugin I linked to solves the problem perfectly and I will install it from now on on every Wordpress install I develop simply because it makes more sense for non technical users when interacting with the media library. Real users struggle is what I am finding.
#6
@
13 years ago
The problem here is that you're hard-coding IDs inside theme templates. Once you do that, the theme is tied to that database; you can't re-use it on other sites.
Instead, a plugin could allow you to register image slots, similar to register_sidebar() or register_nav_menu().
Actually, now that I think of it, my Front-end Editor plugin already allows something like this:
https://github.com/scribu/wp-front-end-editor/wiki/Editing-theme-images
There is a case to be made to bring something like that into Core, but that's another ticket, IMO.
#7
@
13 years ago
It need not be an ID. An alias could be introduced, e.g. "price_badge" that abstracts away from an ID.
I tried a widget called Image Widget which allows you to put images into sidebars. The trouble is, it always comes back to the Media library. It uses it as a basis for placing media assets into zones in the page but as soon as you update an asset that widget breaks too.
I think plugins/sidebars will all struggle to work on top of a core that is fundamentally changing the identity of assets around on updates.
#8
@
13 years ago
Also, the Front End Editor you suggest does not prevent the fact that production sites break as soon as an asset is updated within WP where my users like to manage their sites. They would have to change their whole way of working to interact via the front-end and that's not optimal I think.
#9
@
13 years ago
I'm not really sure what you mean by "as soon as an asset is updated". What's an asset and how do you update it, so that it changes it's ID?
#10
@
13 years ago
Sorry, I've been writing this somewhat incorrectly.
What I mean to say, is that a user *should* be able to update an image in Media library, so that you essentially have asset management.
Right now that ability does not exist, and what my users have done is they just go ahead and create a new image because they can't update the existing one.
This is confusing the user because the front-end is not changing (in the case where I am pulling in via ID).
Sorry for the confusion, I was thinking of a different problem re. the ID changing.
#11
in reply to:
↑ 5
@
13 years ago
Replying to porridgebear:
...
You can't have in asset management/media management, a situation where the user uploads an asset and suddenly it becomes an entirely different asset. It just doesn't align with any other asset/CMS system I have used, and it causes problems.
...
The use-case is using the WP media library to store assets independent of posts...
Right, however the media library is not an "assets manager" for the theme, it's rather a "content manager" mostly for photos. It could be used for assets management but that's not the main functionality.
In any event, the plugin I linked to solves the problem perfectly and I will install it from now on on every Wordpress install...
Exactly, to use the media library as full-featured assets manager you would want to extend that functionality with a plugin. Then perhaps you can add storing of other theme assets in there like css, js, flash animations, etc. depending on your needs.
#12
@
13 years ago
Right now that ability does not exist, and what my users have done is they just go ahead and create a new image because they can't update the existing one.
If you were using Front-end Editor, they wouldn't be tempted to go to the media library, since they could change it right there, without even going to WP Admin.
That said, I think being able to replace an image while preserving the attachment ID might be the only general solution.
For example, say you've just uploaded an image. You then go WP Admin -> Appearance -> Header and select it as the custom header. Then, you go and insert it into the content of 5 pages. When the user wants to replace that image, there's just no practical way to figure out automatically all the places where the image is used.
A plugin implementing a separate "Assets" admin page and the associated register_theme_asset() API would be very interesting indeed.
#13
@
11 years ago
- Keywords 2nd-opinion removed
- Resolution set to wontfix
- Severity changed from major to normal
- Status changed from new to closed
Closing based on discussion above. +1 that it would make a great plugin.
This ticket was mentioned in Slack in #core-media by paaljoachim. View the logs.
7 years ago
This ticket was mentioned in Slack in #core by paaljoachim. View the logs.
7 years ago
This ticket was mentioned in Slack in #core by desrosj. View the logs.
7 years ago
This ticket was mentioned in Slack in #core-media by paaljoachim. View the logs.
7 years ago
This ticket was mentioned in Slack in #core by sergey. View the logs.
5 years ago
This ticket was mentioned in Slack in #core-media by paaljoachim. View the logs.
5 years ago
#25
@
2 years ago
- Resolution wontfix deleted
- Status changed from closed to reopened
The plug-in solution offered for this, Enable Media Replace, was taken over by ShortPixel. Love ShortPixel but they have started adding advertising banners and additional features (delete background) unrelated to the plugins’s original nice simple purpose.
Perhaps it’s time to reconsider adding this simple long needed feature directly to core.
#26
@
22 months ago
This is again why we shouldn't force users to rely on plugins for what should be simple core utility functions like this: https://wpscan.com/vulnerability/b0239208-1e23-4774-9b8c-9611704a07a0
Sure they fixed it promptly, but as these sorts of plugins bloat over time and get handed between maintainers these things happen more and more.
If you replace the image, you would also have to regenerate all the intermediate sizes. Also, you would have to announce the replacement to any external caching services, such as CDNs.
It's not a trivial change.