This is quite an ‘out there’ question but i’ve been thinking about some simplification in my app and if this is at all possible would be a really clean way of doing things.
Please note: I am not looking for comments regarding unneeded optimzation etc. I am well aware that this, however it is something I have been thinking about recently and wondered if it was possible.
Background info:
If you imagine a users ‘cover photo’ similar to those seen on Facebook and Google+. In these apps you can adjust the vertical position of the image by dragging it up or down on your profile page.
This functionality is exactly the same in my app. User drags the image on their profile page, when they let go of the mouse button an ajax post is sent to server and it updates the database with the new ‘top’ value.
This ‘top’ value is read from the database when needed and of course the css is set accordingly. Everything works fine
Question:
So with all that in mind, is there any way, via PHP of storing meta data to a file itself. In this case a .jpg file. I know that you can read certain file info data from files but is this directly customizable? Would it be possible to set a simple meta data property named ‘top’ and give it an integer, allowing this to be read within the app bypassing the need for the database at entirely? If so are there any drawbacks to this method?
If of course this is not possible/desirable then fine. This would also be considered a correct answer, but please explain why.
An unusual question I know. Hopefully somebody will have an insight on this.
You can manipulate exif data, which is meta data stored in images. So theoretically you could ‘save’ the top value in a metadata field… BUT. Don’t do it! It’s likely gonna be overly expensive for the fact that you just want to save one integer. You can’t test it in a standard way, it’s not a standard way of doing things so the next guy will miss it if you don’t document it well, etc. etc. Your database connection is open anyway, likely you have the user in memory, so writing and reading this value from the user profile is really not a big thing. All in all, not a good idea I think, even though it’s original.