Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Roman 9 posts 79 karma points
    Mar 15, 2015 @ 16:24
    Roman
    0

    Custom Media Type server-processed when uploaded in Umbraco 7

    Hi, I'm very new to Umbraco. I like it so far, but now a bit stuck.

    I have to create custom media type DarkOrLightImage, which is basically Image with an extra IsDark (True/False) property. Here are requirements:

    1. IsDark property needs to be set automatically during file upload. I got detection code, but I don't know where to put it. DarkOrLightImage has Upload Image property of Upload DataType. Do I need to alter it or create my own UploadWithDetection DataType which uploades and makes detection? If so, how do I do this?

    2. I have specific media type FolderForDarkOrLightImages which allows DarkOrLightImage as child nodes only. To browse it it has Content property of FolderBrowser DataType, just like standard Folder. But when I use it to upload several DarkOrLightImages, it uploades them as standard Images. Even though Images are not allowed as child nodes for this FolderForDarkOrLightImages media type. I've already searched for solutions, but what I found was old and for previous versions of Umbraco (4, 5). Like this: https://our.umbraco.org/forum/developers/extending-umbraco/28145-Bulk-Upload-Images-(Custom-Media-Type) https://our.umbraco.org/projects/website-utilities/multiple-file-upload Solution is based on altering BulkUpload package but there is no need in it, because Umbraco 7 has FolderBrowser DataType which enables you to do bulk upload. So, do I have to alter FolderBrowser or create my own similar DataType which can bulk upload my DarkOrLightImages (with dark/light detection processing)?

    Anything will be appreciated, because I have just no idea how to create custom DataTypes, where to start. I found DataTypeUploadField in sources

    public class DataTypeUploadField : cms.businesslogic.datatype.BaseDataType, interfaces.IDataType
    

    but it says that

    [Obsolete("IDataType and all other references to the legacy property editors are no longer used this will be removed from the codebase in future versions")]
    

    so I even didn't manage to find it and see how it works. I very need your advice. Thanks!

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 16, 2015 @ 00:09
    Alex Skrypnyk
    0

    Hi Roman,

    Welcome to community. What version of Umbraco are you using?

    1. It will be better to create your custom datatype, without using exisitng.

    How to create property editor for Umbraco 7 - https://our.umbraco.org/Documentation/Extending-Umbraco/Property-Editors/creating-tutorial1-v7

    1. Roman, where are you storing your images ? In the media section or in the content tree ?

    Thanks, Alex

  • Roman 9 posts 79 karma points
    Mar 18, 2015 @ 11:19
    Roman
    0

    Hi Alex! Thanks for response.

    I'm using Umbraco version 7.2.2 assembly: 1.0.5529.18522.

    1. I may be missing something, but tutorial link you provided refers to creating property editor on client-side only, like some special editing functionality. It creates data on a client and it goes into db like some text data. Whereas I need to upload file and do something with it on server side. May be I need to create some class like this? https://github.com/umbraco/Umbraco-CMS/blob/7.2.0/src/Umbraco.Web/PropertyEditors/FileUploadPropertyValueEditor.cs#L87

    2. I store images in Media section under some folder. In the Content section I have Homepage with "ShowcaseImages" property:

      ShowcasePhotos (ShowcasePhotos), Type: Multiple Media Picker

    and I pick photos.

Please Sign in or register to post replies

Write your reply to:

Draft