Copied to clipboard

Flag this post as spam?

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


  • blackhawk 313 posts 1368 karma points
    Dec 11, 2017 @ 21:34
    blackhawk
    0

    Can we add an additional field for Media Picker, giving editors an option to add a class name?

    I'm on Umbraco 7.7.2. I'm gonna have a ton of pages where non-technical editors will be uploading images, via media picker or uploaded through the RTE for content nodes.

    Is there a clever way we can offer an optional field for each image added to a content? The purpose of the field is to allow editors to write in a class name (i.e. half the images uploaded will need bootstraps img-responsive center-block for branding purposes.

    If I should be thinking about an alternative way to go about this, i'm all ears. I just want to reduce an editor from going into code mode of RTE, as much as possible.

    Thanks!

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Dec 12, 2017 @ 09:39
    Kevin Jump
    1

    Hi

    Adding extra fields to the existing pickers isn't really doable - you could write your own media picker - lifting most of the code from the umbraco source - but that is probibly a little over kill,

    The closest 'other' solution i can think of is using editor styles to wrap the image. I will run through the steps below - but before i do, you should note this won't give you the classes on the image, instead it will wrap it in a span with the classes

    <span class="img-responsive center-block"><img style="width: 500px; height: 333.4375px;" src="/media/1030/16403439029_f500be349b_o.jpg?width=500&amp;height=333.4375" alt="" data-udi="umb://media/3d758b1f24ec47b0a75c225b0444991b" /></span>
    

    I know that might be a showstopper so i thought i would put it up front.

    First - either create a new stylesheet or if you already have one for the editor, add a new stylesheet property - by right clicking on the stylesheet and selecting create, this will allow you to create a stylesheet property (for use in the editor) that applied the class.

    enter image description here

    this doesn't have to hold the styles (although it can) it is just so the RTE knows how to wrap the image.

    next add the stylesheet to your RTE control (developer/datatypes)

    enter image description here

    if this works, then when you are editing content you should be able to see the Image center option in the formats box in the RTE.

    enter image description here

    When the editor adds an Image to the RTE if they then select the image in the text and then select this option from the formats dropdown, it will apply the styles to the image (as in the code snippet at the top).

    Its not ideal, and only really an option if you have control of styles for the site, but it's certainly quicker than creating a new media picker.

    the other option i would consider would be maybe using the grid layout to let editors put images into certain places on the page, but again very much dependent on the site, layout and css you are working with.

  • blackhawk 313 posts 1368 karma points
    Dec 12, 2017 @ 15:17
    blackhawk
    0

    Kevin you are man. Thank you so much for the good tips. I didn't know we could do that with custom format options in the RTE. I'm gonna play with that when I get a free minute.

    I was just driving home last night and thought on the way about something that could solve this process. Would you recommend Archetype as a way to mesh-mash media picker with a text field (for a class name on the embedded image). Or maybe a drop-down of formatting options instead of a text field. Would you consider this as an alternative solution?

    Thanks

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Dec 12, 2017 @ 15:22
    Kevin Jump
    1

    Yeah,

    thinking about it if i had to do something like that - I might use a macro to insert images, then the editor can pick the image, and then have another text parameter for the class name. you can then control the html in the Macro View Partial.

    this is similar to an Archetype way i suppose but - would actually render inside the editor, which might feel more 'natural' to your editors.

    Kevin

  • blackhawk 313 posts 1368 karma points
    Dec 12, 2017 @ 15:27
    blackhawk
    0

    Sounds like a good plan. I'm gonna give this a shot in my development learning, and let you know!

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft