![]() |
Removing photos does not remove links to them
When using Reports to identify photos that are not wanted, and then deleting them, the photo disappears off disk, but the link remains in the epub. (For example, some ebooks have a bunch of graphics that are not wanted, and you can easily delete them in the Reports section. But the link stays in the epub.
So, if you run Calibre against the file to convert to another format, it renames all the photos based on how many photos remain in the file - which causes collisions, because the 'old' links have the 'old' names, and Calibre doesn't renumber the links that don't have photos on disk. The result is that there is a mixture of old photo links to photos that don't exist and a group of new link names that reflect actual files on disk. Thus, you end up with photos being shuffled around. There are a couple ways to solve this - In Sigil, if a photo is deleted using the reports image delete feature (which is the only one that lets you see the actual photos you might want to delete), when a photo is deleted, any links in the ebook leading to that photo should be deleted along with the photo. The other solution would be for Calibre to use the provided photo names instead of renumbering them, but that's not likely to happen. Since Calibre always numbers photos and assigns them from zero to however many photos are present (regardless of whether there are links to photos that don't exist) this collision problem remains. The workaround is to manually delete all the placeholders in book view - not too bad for a small ebook, but a real pain of there are tons of them. If I've missed a way to 'clean' those unwanted links out, please let me know. Thanks, John |
There's no way to delete any kind of file (image or otherwise) that will result in all links to those files being automatically removed. The links have to be deleted manually, or with some sort of regex cleanup. Once all links are gone from the html files, the Delete Unused Media tool will show all images that are unused and can be deleted.
It's definitely something that a plugin could be created to do though. Have the plugin present a list of images to delete, and then parse all the xhtml and remove any img tags that refer to the deleted images. |
When you delete a photo from within Sigil, it makes no sense to leave the links to it in the epub. That is my point. That link is totally unusable, and if you have 200 links to the deleted photo, you have to manually delete 200 links.
While it says it is deleting the photo from the ebook, if the link isn't deleted along with it, it is only half-done. I don't see why a plugin should have to be created for something like that - there can't possibly be value in leaving links to a photo that has been deleted from the ebook. |
Quote:
I would agree that it makes more sense to remove all links to a resource when the resource is deleted, and I would try to add the possibility if I were a developer. But then the problem is how to remove the links. Say you have something like this in the code: Code:
<p>The landscape was amazing:</p>Now you remove both images, what should the code look like? Like this? Code:
<p>The landscape was amazing:</p>And if anything is not perfect, you are left with no clue of where the image was supposed to be, so cleaning the result is going to be a little hell. It could be more practical to leave all references there, at least you can still search them and remove them with regex if you wish. |
Hi,
I agree with Jellby. I often will delete an image and later replace it with an improved version. I would not want the link to be removed nor would I want all of the "alt" text I wrote to go away either. So I think DiapDealer's idea of either using a regular expression replacement or a plugin would be the best way to go. Regular Expression search and replacement can easily be done in Sigil right now and there are a number of Regular Expression experts here in this Forum and the Calibre forum can probably show you possible ways to accomplish what you want. The plugin approach would take a bit more work, but perhaps someone will create a selectable toolbox of transformations plugin to make things easier. Something like this might be perfect example case for a tool like that. For example: It could use a regular expression to present a list of all of the img tags and allow the user to either select the ones to keep or the ones to remove. KevinH |
I can see lots of reasons (many have been listed) to always do the 'remove image's as 2 steps.
(I also distrust always in full automatic anything. There are always exceptions ;) ) BTW I prefer to remove the usage FIRST (image use report says 0 used) befor removal. |
The best idea would be an option to remove the link. Like being asked when the image is removed.
|
@JSWolf,
I disagree. That is clearly not the best idea in my opinion. Again, this is something for a plugin or a specially tuned regular expression search and replace to do. In general, this is not an issue for most users one way or the other. Most users do not have to remove 200+ images and their img tags while leaving selected others (and their img tags) untouched. The Sigil interface is already busy/complicated enough. This is exactly the reason we decided to implement a plugin system. If you want that extra feature, then code it up as a "ImageandTagDeleter" plugin and you are good to go. |
Quote:
I agree and that could even go as far as to provide you a list of images (to choose) from. So you chose and delete and it deletes. In addition to automatic delete any images that aren't present. This solves both issues and I agree with KevinH is really best suited for a plugin. |
Definitely a plugin.
Automatic removal of links whenever an image was deleted could easily lead to disaster. I'm imagining a case where someone wants to replace a scene-break graphic that's littered throughout their finished-but-looking-for-a-little-polish ebook. Imagine their dismay when instead of simply deleting and adding the new scene-break image, they discover they have to recreate hundreds of image tags that went away. |
Quote:
|
Quote:
No need to modify Sigil's codebase to provide an "are you sure" button attached to a new context menu that's going to run code that a plugin could do just as well. |
| All times are GMT -4. The time now is 09:15 PM. |
Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.