Copied to clipboard

Flag this post as spam?

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


  • Craig100 1136 posts 2523 karma points c-trib
    Feb 18, 2015 @ 00:10
    Craig100
    0

    How to get to Media Picker within an MNTP

    I have a Media Picker call "productImages" which resides in an element in an MNTP. I have the core property value converter installed.  How do I get through to the image in the Media Picker? Have tried a few options, all fail on the var productImage line

    Code:-

    var accessoriesList = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("compatibleAccessories");  //The MNTP
    var productImage = accessoriesList.GetPropertyValue<IPublishedContent>("productImage"); //The media picker

    Any hints appreciated.

    Craig

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 18, 2015 @ 00:14
    Jan Skovgaard
    0

    Hi Craig

    What is the above code outputting currently? And is it correct to assume you're using v7.2.x? :)

    /Jan

  • Craig100 1136 posts 2523 karma points c-trib
    Feb 18, 2015 @ 00:56
    Craig100
    0

    Hi Jan,

    It's outputting-

     

    Compiler Error Message: CS1928: 'System.Collections.Generic.IEnumerable<Umbraco.Core.Models.IPublishedContent>' does not contain a definition for 'GetPropertyValue' and the best extension method overload 'Umbraco.Web.PublishedContentExtensions.GetPropertyValue<T>(Umbraco.Core.Models.IPublishedContent, string)' has some invalid arguments

    Craig
  • Craig100 1136 posts 2523 karma points c-trib
    Feb 18, 2015 @ 01:21
    Craig100
    2

    Hi Jan,

    Sorted it. Completely cocked it up. Final code working:-

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        if(Model.Content.HasValue("compatibleAccessories")) {
            var accessoriesList = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("compatibleAccessories");
    
            if(accessoriesList.Any()){
                <h2>Compatible accessories</h2>
                <div class="container">
                @foreach(var accessory in accessoriesList) {
                    var productImage = accessory.GetPropertyValue<IPublishedContent>("productImage");
                    <div class="col-m-4 text-center">
                        <img src="@productImage.GetResponsiveCropUrl("AccessoryThumbnail")" alt="@productImage.Name">
    
                    </div>                                            
                }
                </div>
            }
        }
    }
  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Feb 18, 2015 @ 08:29
    Jeavon Leopold
    0

    Looks good to me Craig!

  • Craig100 1136 posts 2523 karma points c-trib
    Aug 13, 2016 @ 17:38
    Craig100
    0

    Not sure if I should open this up again or start a new one, but it's essentially the same just 18 month and serveral versions on........

    Umb 7.4.3, Slimsy 1.1.7 and Umbraco Core Property Value Converters.

    1) VS complains "IPublishedContent does not contain a definition for GetResponsiveCropUrl.....". It's retrieving an image from a single source MultiMedia Picker. It worked before I added Slimsy and changed the src URL code.

    2) HTML is output but no image shows. Have re-saved the image but to no avail.

    Code:

        var eventImage = item.GetPropertyValue<IPublishedContent>("eventImage");
    
        if(eventImage != null) {
            <div class="col-m-3 diaryPic">
                <img src="@eventImage.GetResponsiveCropUrl("diaryPic")" alt="@eventImage.Name">
            </div>
            <div class="col-m-9">
                @item.GetPropertyValue("eventDescription")
            </div>
        } else {
            <div>
                @item.GetPropertyValue("eventDescription")
            </div>
        } 
    

    HTML:-

    <img data-src="/media/14003/mypic2096020x20460-1-.jpg?anchor=center&amp;mode=crop&amp;width=300&amp;heightratio=0.75&amp;format=jpg&amp;quality=90&amp;slimmage=true&amp;rnd=130926588680000000" alt="mypic2096020x20460 1 " data-slimmage="true">
    

    Have tried putting the Slimsy JS code in header and where I'd normally put it, at the top of the JS file list in the bottom of the page.

    Any help appreciated as I'm in my usual Umbraco syntax hell.

    Thanks.

  • Craig100 1136 posts 2523 karma points c-trib
    Aug 13, 2016 @ 17:56
    Craig100
    0

    For Item 1) I should mention Slimsy was installed with NuGet.

    For item 2) I tried clearing cookies. However, have found that if I resize the browser window, the image appears, but doesn't on page load. So I guess it's a JS issue or clash with responsiveBP? I have img max-width set to 100%.

  • Craig100 1136 posts 2523 karma points c-trib
    Aug 14, 2016 @ 10:17
    Craig100
    0

    Item 2) WRT: https://our.umbraco.org/projects/website-utilities/slimsy/slimsy-feedback/54003-Strange-resizing-of-images#comment-187327

    I think I've found the issue. Client wanted smooth animation from blank page load, so HTML has a background of #000 and body display:none initially. Then the animation JS kicks in and moves things around and gradually fades them up in opacity. This would explain why Slimsy isn't doing it's stuff until you get a browser resize.

    Question is I suppose, is there some technique that will give the same end result and allow Slimsy to work? Maybe build the page content out of view, then set it's display to none, move it into the viewport then start the animation.

    Sorry for the self-rumination. Hope it helps someone else with the same issue. I'll report back on results.

    No progress on item 1) VS issue though.

Please Sign in or register to post replies

Write your reply to:

Draft