Copied to clipboard

Flag this post as spam?

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


  • jake williamson 207 posts 872 karma points
    Aug 22, 2019 @ 02:09
    jake williamson
    0

    media picker that restricts to image and svg files in v8?

    hey out there,

    in the past the main way i've saved the 'i want to pick an image or an svg' media picker is to use the multinode tree picker, something a little like this:

    enter image description here

    sure you lost the image thumbnail but it got the job done ;)

    so i thought i'd use the same idea in v8 however the 'allow items of type' option of the multinode tree picker is no longer a text box!

    enter image description here

    worse still, even though i've selected a node type of 'media' i can only select doctype based types - media types aren't available...

    i can't use a regular media picker with the 'disable folder select' option checked as it doesn't restrict the file type...

    short of building my own property editor, is there a different solution out there to this?!

    cheers,

    jake

  • Chris Evans 137 posts 353 karma points c-trib
    Aug 22, 2019 @ 04:08
    Chris Evans
    0

    I could be wrong, but aren't SVGs just treated as normal image files now when you upload them to media?

  • Chris Evans 137 posts 353 karma points c-trib
    Aug 22, 2019 @ 04:13
    Chris Evans
    0

    No I'm wrong - if you choose Pick only images then SVGs are disallowed.

  • jake williamson 207 posts 872 karma points
    Aug 22, 2019 @ 04:16
    jake williamson
    0

    yeah... that's what i was hoping would be the case!

    there must be something in the core though that sets what umbraco considers to be a image?

    gonna have a dig in the source...

  • jake williamson 207 posts 872 karma points
    Aug 22, 2019 @ 06:11
    jake williamson
    0

    ok, so i did some digging in the source code and found this:

    enter image description here

    then i found this:

    https://our.umbraco.com/documentation/Reference/Config/umbracoSettings/

    the above seems to indicate you could do something like this in the content section of the umbracoSettings.config:

    <imageFileTypes>jpeg,jpg,gif,bmp,png,tiff,tif,svg</imageFileTypes>
    

    so i gave it a go and umbraco blows up!

    feels like i'm heading in the right direction though...

    interestingly, we're using a custom build of v8 at the moment so i might just try and change the line:

    return new[] {"jpeg", "jpg", "gif", "bmp", "png", "tiff", "tif"};
    

    in the src\Umbraco.Core\Configuration\UmbracoSettings\ContentImagingElement.cs file adding svg to the list and seeing if it works!

  • jake williamson 207 posts 872 karma points
    Aug 22, 2019 @ 23:42
    jake williamson
    104

    so, after reporting the bug with regards to the multinode treepicker it appears that it's already been reported:

    https://github.com/umbraco/Umbraco-CMS/issues/5983

    i was searching for 'multinode treepicker' rather than 'mntp' otherwise i guess i would've found it!

    the good news is it's pr stage:

    https://github.com/umbraco/Umbraco-CMS/pull/6177

    the bad news is it's blocked so i'm not 100% sure when it'll get merged in.

    meanwhile though i've been doing some more digging and found the solution is to add this to the <content> section of the umbracoSettings.config file:

    <imaging>
        <!-- what file extension that should cause Umbraco to create thumbnails -->
        <imageFileTypes>jpeg,jpg,gif,bmp,png,tiff,tif,svg</imageFileTypes>
        <!-- what attributes that are allowed in the editor on an img tag -->
        <!--<allowedAttributes>alt,border,class,style,align,id,name,onclick,usemap</allowedAttributes>-->
        <!-- automatically updates dimension, file size and extension attributes on upload -->
        <!--
        <autoFillImageProperties>
            <uploadField alias="umbracoFile">
                <widthFieldAlias>umbracoWidth</widthFieldAlias>
                <heightFieldAlias>umbracoHeight</heightFieldAlias>
                <lengthFieldAlias>umbracoBytes</lengthFieldAlias>
                <extensionFieldAlias>umbracoExtension</extensionFieldAlias>
            </uploadField>
        </autoFillImageProperties>
        -->
    </imaging>
    

    i added svg to the list of imageFileTypes and hey presto i can now select svg files from a data type based on 'media picker' with 'pick only images' and 'disable folder select' checked.

    happy days! it was good to go down the rabbit hole with regards to the multinode tree picker too, fingers crossed that bug will get resolved soon.

Please Sign in or register to post replies

Write your reply to:

Draft