noumo / easyii

Easy yii2 cms powered by Yii framework 2
http://easyiicms.com
592 stars 270 forks source link

Add possibility to set filename when create new File #94

Open torejx opened 9 years ago

torejx commented 9 years ago

Hi Noumo,

This is my problem: I've some css classes that use images as background, for example:

.bg01{
  background-image: url('/images/bg01.jpg');
}

I want to let the user change the background using the cms interface, so I think it's a good idea to create a File for each background with a fixed filename, so the user can change the File (the image) and I don't need to change the css.

It's my first pull request, I hope it could be usefull.

Thanks!

boehsermoe commented 8 years ago

I think that possible already. If you upload a file, it will be place under "uploads/file/bg01.jpg", you can use this for your url. Maybe the file module should get a setting for the dir. Than you could create a copy of the file module and named "system". The "normal" files would be placed under "uploads/file/foo.jpg" and the "system" files like your background image under "uploads/system/bar.jpg".

torejx commented 8 years ago

But what happens when the user decide to change the background image? I should tell him to rename the new image as the old one to keep my css rule valid.

boehsermoe commented 8 years ago

Ok. What is when the slug name will be used as filename? The slug is unique and I'm not sure what happen, when you create two file-item with the same filename (but different content). With the slug name solution each file-item have there own unique file.

torejx commented 8 years ago

Good idea! Do you suggest a flag "use slug as filename" instead of the text box?

boehsermoe commented 8 years ago

I dont think it a good idee to give the user this extra option. I favor to use always the slug as filename and just give the user a hint, that the slug used as filename and the file extension will just append to the slug.

torejx commented 8 years ago

But in this way you override the default behavior. I don't know if it's a valid option.

boehsermoe commented 8 years ago

Yes, but is the current behavior valid? Multiple file-item can use the same filename and maybe override each other. The slug-filename-solution could be a better "default" behavior.

torejx commented 8 years ago

I agree. What can we do? Have you already performed a pull-request? Should I change mine?

boehsermoe commented 8 years ago

No, I have no a pull-request for this. Best you change this or create a new one.