Change Media Name before upload



  • Hey !

    Great work for this wonderfull cms, but just a suggestion. It could be usefull to change the name of the uploaded media before upload it. When I've looked the mediaController I've not found the store method to change the filename. Where can I found it ?

    Thanks you =)


  • admin

    Hello,

    Thank you. :)

    Hm, what would be the use-case for this ?
    It might be more user-friendly to add this option once the file has been uploaded.

    The storage of the files can be found here https://github.com/AsgardCms/Media/blob/master/Services/FileService.php#L33



  • Hey,

    It could be useful for SEO google images, or if the file name is not correct (as DCIM9890.jpg for example), to have correct saved name in the database for relations with pages or others modules.

    Yes maybe after the upload, but it will be more useful to determine it before upload the file, in a step and not two ;)


  • admin

    true, but giving we're using Dropzone, I don't know if that's possible.



  • Hey !

    Of course it's possible, I make it in one of my projects. Just set a text field to have a name and after you do the treatment. And to reuse the new name you keep the original name and the new name in an array you use to remove media. For multiple medias you can add a random at the end of the new name to avoid conflicts.


  • admin

    Interesting, maybe you can send a PR with that change since you know how to do it already ? :)


Log in to reply