OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.36k stars 2.37k forks source link

Media Library features similar to Orchard 1 #3404

Open tidou opened 5 years ago

tidou commented 5 years ago

Dear development team, hello! I have a request, I don't know if it can be implemented, the new version is very good, not enough media manager is not perfect, can you add Orchard.MediaLibrary module like orchard1, so that the added media files can record data and edit in the database. And achieve the relevant authority control, thank you!

scleaver commented 5 years ago

I have to say I agree with @tidou - I haven't really looked at version 1 of Orchard but I really do think that media files need to have some additional data stored against them as just having the file is a bit limited.

All media:

Some file types might need some additional fields: Images

Video

Also I think the media field should associate the media item by ID rather than path if possible. The relationship should be removed if the media is deleted.

arkadiuszwojcik commented 5 years ago

I also think that media item should be identify by ID, with option to have some metadata fields. That might be usefull to implement responsive images #3273 , one of such field could hold paths to numerus images of different sizes.

sebastienros commented 5 years ago

Assets are files on purpose. The idea is that when we don't have custom metadata on a file we should not have to load a content item from the database to render it.

But it's still doable, just create a type named Image and add a media field to it, plus any other metadata you need. Then you can use the Content Field Picker to select an Image like this.

You can even organize then with Taxonomy, or tags...

matiasmolleja commented 5 years ago

Yes. Many of the features suggested can be achieved by wrapping the field in a content part A video content part, image content part, etc... We should keep the field simple I think

scleaver commented 5 years ago

@sebastienros - so the uncomplicated nature of media at the moment is a performance decision? eg. no DB lookup so better performance?

sebastienros commented 5 years ago

Correct, most sites don't need to overhead of image metadata. And it's still doable on a per usage basis.

tidou commented 5 years ago

The general CMS website does not need to record media files such as jpg, doc, pdf, MP3, etc., but if you do a document management system, uploading files directly to the database will be convenient and intuitive, just like the windwos manager, I feel Orchard1 Orchard.MediaLibrary is very good, uploading document records data, and can do permission control. Strongly request the development team to consider adding this function module. Those of us who do the management system will be very grateful for your contribution!

Skrypt commented 5 years ago

I would probably favor the use of some .json file or a single database row with JSON that would store files metadata for making import/export easier than in 01. I know that in 01 we needed to have a media sync button that would reimport all files missing to the database and that would create a single row per file in the database which made this awkward for retrieving a specific media item by it's Id. Somehow it is easier to just be able to copy/paste a file in the media folder to get it accessible from your website frontend than to require to do a SQL query to retrieve it with it's metadata. And we could simply cache that JSON data on runtime.

Also for identifying a media item we could run a MD5 checksum and store it in that JSON. Simple as doing this :

using System.Security.Cryptography.MD5;

using (var md5 = MD5.Create())
{
    using (var stream = File.OpenRead(filename))
    {
        return md5.ComputeHash(stream);
    }
}

static string CalculateMD5(string filename)
{
    using (var md5 = MD5.Create())
    {
        using (var stream = File.OpenRead(filename))
        {
            var hash = md5.ComputeHash(stream);
            return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
        }
    }
}

This could be a good way to also identify files that are duplicates.

sebastienros commented 5 years ago

I will never repeat it enough, if you really want it, it's 4 clicks away, create a content type and add aefia field, or two, or three, plus text fields, ...

One day we might work on some predefined solution, as predefined content types, but building block is already there. Bonus, you don't have to delete the media types that don't match your needs.

Skrypt commented 5 years ago

Yeah I agree with that too.

agriffard commented 3 years ago

Media text as been added.

/cc @deanmarcussen