First of all , i hope i posted this in the correct forum..
Anyhow, in umbraco 4.9 there's a new upload functionality which makes life a lot easier :)
However, i like to use custom media types for specific types of images. I usually do this for cropping functionality for certain types of images. Say we have a media type 'ProductImage' which has certain crops specified which normal images don't.
How does this upload functionality work with these custom media types? Is there any place where i can say for example: upload extensions jpg, png, etc in this folder as media type 'ProductImage'? Or are there any other options I have in order for this to work?
Thanks for the reply! I'll check it out. I used to 'solve' this by using a custom upload control. Is there a way of disabling this new upload mechanism? Else i'll have customer using this upload causing problems ...
Why haven't custom media types been included when creating this new media section interface? Now I have to explain to my client's that although there is an upload button there, you can't actually use it. The media section is where Umbraco falls behind the competition - it's just clunky and needs plug-ins to enhance it, and the plug-ins never quite work right anyway. I get that it's open source software, but it's just annoying that such a great CMS is let down by media management.
Here is what we used, following Flavio's example and also sharing the using statement.
We called this file \App_Code\UmbracoMediaFactories.cs
using umbraco.cms.businesslogic.media;
namespace FyinDotCom.MyCustomFactory
{
public class MyCustomImageMediaFactory : UmbracoImageMediaFactory {
public override string MediaTypeAlias {
get { return "galleryCrop"; }
}
}
}
I have a follow-up question. I would like the MediaTypeAlias in your example to be different based on the media folder where the media is being uploaded. For example, I have a "gallery" folder, and everywhere else I would like the default media type to be used in uploads, except for the "gallery" folders where I have a "gallery image" type.
Hi Flavio. I was referring to the code above, this seems to define the default media type for Umbraco, but what if the default media type depends on the folder where someone is uploading images?
For example, I have a "gallery" folder, and I would like only "gallery images" to go in that folder, but everywhere else I would like the regular "image" media to be created.
You can select "Gallery images" Media-type as unique "allowed child nodetype". You can do this with Backoffice: Settings / MediaTypes / "Gallery" nodetype, then "Structure" page of tabstrip.
Right, and I see that and I have done that... but when I go to another folder called "MyOtherFolder"... I don't want to upload gallery images. Instead I would rather upload "Image" images.
Ok, then you will set the right "allowed child nodetype" for "MyOtherFolder".
I think that there are something that I don't understand the target of issue...
Ok, I was able to get it working for a "gallery" folder only.
Here is the code:
using System; using System.Collections.Generic; using System.Linq; using System.Web;
using umbraco.BusinessLogic; using umbraco.cms.businesslogic.media;
namespace MyCustomFactories {
public class MyGalleryImageMediaFactory : UmbracoImageMediaFactory {
public override string MediaTypeAlias { get { // The type of media this factory produces return "GalleryImage"; } }
public override int Priority { get { // Making sure my factory is earlier in the list of candidate factories (Base class uses 1000) return 500; } }
public override bool CanHandleMedia(int parentNodeId, PostedMediaFile postedFile, User user) { // Decide whether this factory applies; If not, another factory will be used (i.e. the base class) bool isGalleryParent = false;
if (parentNodeId != -1) { Media parent = new Media(parentNodeId); isGalleryParent = parent.ContentType.Alias == "Gallery"; } else { isGalleryParent = false; }
umbraco 4.9 - default upload / custom media types
Hi all,
First of all , i hope i posted this in the correct forum..
Anyhow, in umbraco 4.9 there's a new upload functionality which makes life a lot easier :)
However, i like to use custom media types for specific types of images. I usually do this for cropping functionality for certain types of images. Say we have a media type 'ProductImage' which has certain crops specified which normal images don't.
How does this upload functionality work with these custom media types? Is there any place where i can say for example: upload extensions jpg, png, etc in this folder as media type 'ProductImage'? Or are there any other options I have in order for this to work?
I hope i've been clear enough..
Thanks in advance,
Vincent
Hello,
This doesn't work in 4.9. Have a look at this issue: http://issues.umbraco.org/issue/U4-698. I created a pull request for it, but it got rejected: http://umbraco.codeplex.com/SourceControl/network/forks/jbreuer/CustomMediaTypeWebserviceFromJB/contribution/3313.
Jeroen
I'm currently working on DAMP 3.0 and I will to try to add an uploader in there which works the same as the 4.9 version, but with support for custom media types. Until than you can use this: http://our.umbraco.org/projects/website-utilities/multiple-file-upload/bugs/20286-Support-for-custom-Media-Types.
Jeroen
Thanks for the reply! I'll check it out. I used to 'solve' this by using a custom upload control. Is there a way of disabling this new upload mechanism? Else i'll have customer using this upload causing problems ...
Why haven't custom media types been included when creating this new media section interface? Now I have to explain to my client's that although there is an upload button there, you can't actually use it. The media section is where Umbraco falls behind the competition - it's just clunky and needs plug-ins to enhance it, and the plug-ins never quite work right anyway. I get that it's open source software, but it's just annoying that such a great CMS is let down by media management.
I resolved the problem.
This is the "App_Code/UmbracoMediaFactories.cs" code:
Awesome work Flavio, thanks very much!
Here is what we used, following Flavio's example and also sharing the using statement.
We called this file \App_Code\UmbracoMediaFactories.cs
No other code is necessary.
That's great. Thank you.
I have a follow-up question. I would like the MediaTypeAlias in your example to be different based on the media folder where the media is being uploaded. For example, I have a "gallery" folder, and everywhere else I would like the default media type to be used in uploads, except for the "gallery" folders where I have a "gallery image" type.
Hi Biagio, I haven't sure to understand your question. But I try to answer.
To obtain a custom folder you need to create a new MediaType that inherits by "Folder" mediaType.
Hi Flavio. I was referring to the code above, this seems to define the default media type for Umbraco, but what if the default media type depends on the folder where someone is uploading images?
For example, I have a "gallery" folder, and I would like only "gallery images" to go in that folder, but everywhere else I would like the regular "image" media to be created.
You can select "Gallery images" Media-type as unique "allowed child nodetype". You can do this with Backoffice: Settings / MediaTypes / "Gallery" nodetype, then "Structure" page of tabstrip.
Right, and I see that and I have done that... but when I go to another folder called "MyOtherFolder"... I don't want to upload gallery images. Instead I would rather upload "Image" images.
Ok, then you will set the right "allowed child nodetype" for "MyOtherFolder".
I think that there are something that I don't understand the target of issue...
Ok, I was able to get it working for a "gallery" folder only.
Here is the code:
is working on a reply...