Re-use of existing attachments

https://www.phpbb.com/ideas/
Post Reply
User avatar
EA117
Registered User
Posts: 1391
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re-use of existing attachments

Post by EA117 »

We do a lot of other things in the name of controlling how much space is consumed by attachments on a phpBB board. While finding and re-using my existing attachment without duplicating or re-attaching the same image again for a post today, it made me finally ask "Why isn't this easier?"

Finding the message with the attachment you want to re-use is one aspect. It might be one of your own previous attachments, or it might have been posted by someone else. But phpBB Search isn't going to help you find messages with attachments, or match against metadata related specifically to the attachment.

And then even once you do find the attachment you want, if it's an image with a thumbnail there is the chore of "mimicking" the phpBB handling of an attachment. i.e. An [img] tag for the thumbnail URL, and a [url] tag for the full view link. Less so with other attachment types that aren't images.


So the thoughts that came to mind for me were these:
  • Update phpBB Search to help find attachments.

    Provide options to search "only messages with attachments." And similar to the "search only subject" and "search subject and body", provide a "search subject and body and attachment data." In order to search the attached file name and/or file name extension (.PNG, .SVG, etc.), and the additional optional description that can be provided for an attachment. These features make sense even on their own for phpBB Search, but the intention is that we will also leverage their existence in the next bullet points, too.
    • Update phpBB Attachment interface to allow selecting existing attachments.

      In addition to "Add File", there would be a "Use Existing Attachment" which launches a paginated view of existing attachments. By default, perhaps it only shows your own attachments, sorted in descending order of most recent use in a message. But which you could change to find the attachments of a different specific user, or of all users, and matching specific keywords, and sorted by when the attachment was first used instead of most recently used, etc.
      • Handle the re-used attachment so that it "looks like a normal attachment" to the user composing their new message.

        Meaning, the re-used attachment should be shown in the attachments list at the bottom of the message just like any other attachment the user may have uploaded. And/or will be inserted inline using an [attachment=filename] code like any other attachment normally would. I believe "looking like a normal attachment in the newly-composed message" is probably the more familiar and intuitive behavior for users, if they then want to "remove the attachment they re-used" later or similar. Regardless of whether it was a new attachment or a re-used existing attachment reference.
        • Evaluate whether an attachment reference count can be implemented.

          Now that the attachment can be "officially referenced" in more than one message, do we need a reference count against the attachment. So that the attachment does not qualify as "orphaned" unless all of the messages that used it have been deleted.

        Sounds like something which might be more important to support staff like phpbb.com/community support staff, where "re-referencing the same examples, configuration files, etc." might be a common task. But maybe normal end-users might have some use cases too; like finding a favorite meme image to re-use again.

        User avatar
        kinerity
        Community Team Member
        Community Team Member
        Posts: 2558
        Joined: Mon Sep 01, 2014 1:00 am
        Location: sudo rm -rf /
        Name: Kailey Truscott
        Contact:

        Re: Re-use of existing attachments

        Post by kinerity »

        I like this idea, but the problem you're going to run into is that currently the attachment table references post_msg_id and topic_id. I guess those could be eliminated if every post/pm referenced that attach_id, but that would probably require major changes to the code.
        Kailey Truscott - Community Team

        User avatar
        thecoalman
        Community Team Member
        Community Team Member
        Posts: 3512
        Joined: Wed Dec 22, 2004 3:52 am
        Location: Pennsylvania, U.S.A.
        Contact:

        Re: Re-use of existing attachments

        Post by thecoalman »

        In addtion to the options you have listed it would be nice if existing attachments were searched for same file name, size etc. If a match is found give the user a dialogue box with thumb. "You may have already uploaded this file, use existing file instead?"
        And then even once you do find the attachment you want, if it's an image with a thumbnail there is the chore of "mimicking" the phpBB handling of an attachment. i.e. An [img] tag for the thumbnail URL, and a [url] tag for the full view link. Less so with other attachment types that aren't images.
        I have custom mod with drop down menus and using JS to copy to clipboard, one of the choices is "copy BBcode"

        https://clipboardjs.com/
        “Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

        Attributed - Thomas Edison

        User avatar
        EA117
        Registered User
        Posts: 1391
        Joined: Wed Aug 15, 2018 3:23 am
        Contact:

        Re: Re-use of existing attachments

        Post by EA117 »

        kinerity wrote:
        Sat Feb 22, 2020 1:45 am
        ...the problem you're going to run into is that currently the attachment table references post_msg_id and topic_id. I guess those could be eliminated if every post/pm referenced that attach_id, but that would probably require major changes to the code.
        Ugh. Yeah, that probably means any solution will either fit imperfectly in the existing design, or will require some significant changes to this existing 1:1 assumption in order to make it fit perfectly. Will have to keep thinking on what kind of approach might fit correctly while creating the least impact to the rest of the code.

        thecoalman wrote:
        Sun Feb 23, 2020 3:36 am
        In addition to the options you have listed it would be nice if existing attachments were searched for same file name, size etc. If a match is found give the user a dialogue box with thumb. "You may have already uploaded this file, use existing file instead?"
        That sounds like a good addition.

        I thought along the lines of "make attachment re-use entirely transparent." i.e. Have an SHA256 or other hash on the existing uploads, and when someone uploads a file with the same content (regardless of file name) we just reference the existing /files entry with that same content, if there is one. Without even needing to tell the user, because it's just standard "file system de-duplication" processing at that point, and no reason they need to be told or aware of how phpBB internally manages /files directory content.

        While "totally transparent" is a fine stand-alone idea, doing only that missed the case of "it should have been easy to visually find and re-reference an existing attachment." i.e. What if I don't have that original file, or wouldn't know where to find it to re-upload it... but phpBB already has it, if it would just help me search for messages with attachments. So like you said, it could only be "in addition to" the other options listed.

        But "totally transparent" would be an option of what to do instead of "prompt them to say they seem to be uploading the same file again." If they're uploading the same file again, totally let them, but simply ignore and use the attachment that was already uploaded previously. i.e. Don't grow the /files folder just because someone chose to uploaded the same file again. Obviously based on more than just the file name and metadata match; we have to believe the actual file content is still a match.

        User avatar
        AmigoJack
        Registered User
        Posts: 5702
        Joined: Tue Jun 15, 2010 11:33 am
        Location: グリーン ヒル ゾーン
        Contact:

        Re: Re-use of existing attachments

        Post by AmigoJack »

        Yes, I'm in. My thoughts about it:
        1. Upon wanting to delete an attachment the confirmation page should also tell how often the attachment is used (also when not used at all, and unbound to if posts or messages using it can be accessed by the owner or not).
        2. There are people out there not used to hardlinks or never understanding the concept - they still assume copies all over.
        3. A few board owners want to switch off such a feature entirely, tho. One might want to create duplicates on purpose, unbound to the reason of the purpose.
        4. "Hashing the file" versus "same content" is an issue I collected experience with and whoever relies on this should be aware that phpBB will never be that sophisticated to detect duplicates of files on their payload alone and disregarding the metadata. Examples:
          1. Two MP3s can have exactly the same music in the same encoding, but their title description can differ.
          2. Two JPEGs can have exactly the same picture in the same encoding, but their comment can differ.
          3. Two texts can have exactly the same words and lines in the same encoding, but their newlines format differ.
          It's always up to the context/will of a person on when something should be considered "same".
        The worst thing about censorship is ███████████
        Affin wrote:
        Tue Nov 20, 2018 9:51 am
        The problem is probably not my English but you do not want to understand correctly.
        ...
        We will not come anybody anyway, nevertheless, it's best to shit this.

        Post Reply

        Return to “phpBB Ideas”