Bug 39812

Summary: Add the ability to replace an uploaded image
Product: Koha Reporter: Christopher Brannon <cbrannon>
Component: ToolsAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: dcook
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:

Description Christopher Brannon 2025-05-01 20:56:17 UTC
It would streamline the process of replacing an image if we could simply replace the upload file without changing the link or anything else.  If we have to replace an image, we have to upload a new one, copy the link, and replace any references to the old image.  Replacing the file would allow a quick and simple process.
Comment 1 Owen Leonard 2025-05-01 21:19:16 UTC
Replace images where?
Comment 2 Christopher Brannon 2025-05-01 23:22:19 UTC
(In reply to Owen Leonard from comment #1)
> Replace images where?

Where ever Koha stores images when you upload them.
Comment 3 David Cook 2025-05-01 23:52:13 UTC
Are you referring to the "Tools > Uploads" feature? 

--

It looks like the key is a MD5 hash of a whole bunch of different parameters. 

For temporary uploads, the time of the upload is one of the parameters, which is weird.

For permanent up loads, time isn't used.

But for all uploads, the first 2048 bytes of the file is also used as one of the parameters. 

Honestly, I find that a bit... wild. Surely just hashing the category + filename would've been sufficient.

That said... if you replace the contents of a file and don't change the hashvalue, you could experience caching problems. 

Pros and cons to the different methods. I suppose there could be a system preference that allows for different methods for computing the hash value. 

Not something I'm likely to work on, but it's an interesting idea. 

It actually makes you think a bit about the philosophy of files and documents in general. What IS the document? Is it the name, is it the content, etc. 

Anyway, if you're not referring to "Tools > Uploads", then the answer might be something else.
Comment 4 Christopher Brannon 2025-05-02 14:48:52 UTC
Honestly, I am referring to any file that can be uploaded.  Yes, the Tools --> Uploads is one example, but cover images, patron images, documents linked in records.  There should be a process to replace these files without having to break any links to them.
Comment 5 David Cook 2025-05-05 00:38:05 UTC
(In reply to Christopher Brannon from comment #4)
> Honestly, I am referring to any file that can be uploaded.  Yes, the Tools
> --> Uploads is one example, but cover images, patron images, documents
> linked in records.  There should be a process to replace these files without
> having to break any links to them.

So they all use different mechanisms. Cover images should already be replaceable I think. Same for patron images. 

Not sure what you mean by "documents linked in records". That might be the upload.pl cataloguing plugin? That one would be the same as what I've described above. But then changing a URL when editing a record shouldn't be a big deal.
Comment 6 Christopher Brannon 2025-05-06 16:18:16 UTC
Yes, upload.pl.  That is not a plugin as far as I can tell.  But this one definitely does not have a mechanism for replacing a file.  I can delete, and I can upload (which is goofed up, by the way - if I delete a file, then try to upload, it doesn't do anything, and I have to do it again).
Comment 7 David Cook 2025-05-07 06:02:22 UTC
(In reply to Christopher Brannon from comment #6)
> Yes, upload.pl.  That is not a plugin as far as I can tell.  But this one
> definitely does not have a mechanism for replacing a file.  I can delete,
> and I can upload (which is goofed up, by the way - if I delete a file, then
> try to upload, it doesn't do anything, and I have to do it again).

Is it the one that you access through the cataloguing editor?

The underlying script used for that is "cataloguing/value_builder/upload.pl" which sometimes gets referred to as a "cataloguing plugin" - different thing from a Koha Plugin.
Comment 8 Christopher Brannon 2025-05-07 15:06:05 UTC
(In reply to David Cook from comment #7)
> (In reply to Christopher Brannon from comment #6)
> > Yes, upload.pl.  That is not a plugin as far as I can tell.  But this one
> > definitely does not have a mechanism for replacing a file.  I can delete,
> > and I can upload (which is goofed up, by the way - if I delete a file, then
> > try to upload, it doesn't do anything, and I have to do it again).
> 
> Is it the one that you access through the cataloguing editor?
> 
> The underlying script used for that is "cataloguing/value_builder/upload.pl"
> which sometimes gets referred to as a "cataloguing plugin" - different thing
> from a Koha Plugin.

No, it is through tools: /cgi-bin/koha/tools/upload.pl