Copied to clipboard

Flag this post as spam?

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


  • k 256 posts 654 karma points
    Jul 04, 2017 @ 11:08
    k
    0

    Using slimsy

    Hello,

    I am using slimsy and below is my code :

    'var productImage = Umbraco.Content(CurrentPage.uploadBanner);

                     <img src="@productImage.GetResponsiveCropUrl("large")" />`
    

    large is my crop name.

    But the image is not appearing.

    Can someone please advise what I am doing wrong.

    Thanks,

    kusum

  • Alex Skrypnyk 6162 posts 24132 karma points MVP 8x admin c-trib
    Jul 04, 2017 @ 12:45
    Alex Skrypnyk
    0

    Hi Kusum

    Can you check "productImage" on null"? Can you debug and check what is in "productImage" variable?

    Alex

  • k 256 posts 654 karma points
    Jul 05, 2017 @ 06:27
    k
    0

    Hello Alex,

    Thanks for our reply .

    When using :

    'var productImage = Umbraco.Content(CurrentPage.uploadBanner);
    

    I get null value for productImage.

    But when I use :

    'var productImage = CurrentPage.uploadBanner;
    

    I get the image. But I do not know how to use "GetResponsiveCropUrl" on "CurrentPage.uploadBanner".

    Please let me know If I am not clear.

    Thanks,

    kusum

  • Alex Skrypnyk 6162 posts 24132 karma points MVP 8x admin c-trib
    Jul 05, 2017 @ 08:35
    Alex Skrypnyk
    0

    What about this code:

    CurrentPage.uploadBanner.GetResponsiveCropUrl("large")
    
  • k 256 posts 654 karma points
    Jul 05, 2017 @ 09:09
    k
    0

    Tried this as well. not working.

  • Alex Skrypnyk 6162 posts 24132 karma points MVP 8x admin c-trib
    Jul 05, 2017 @ 09:16
    Alex Skrypnyk
    0

    What about this one:

    @{
        var productImage = Umbraco.AssignedContentItem.GetPropertyValue<IPublishedContent>("uploadBanner");
    }
    <img src="@Slimsy.GetResponsiveCropUrl(productImage, "large")" />
    
  • k 256 posts 654 karma points
    Jul 05, 2017 @ 10:13
    k
    0

    got the below as error :

    Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: mediaItem

  • k 256 posts 654 karma points
    Jul 05, 2017 @ 10:14
    k
    0

    But When I do CurrentPage.uploadBanner , I do get a value

  • Alex Skrypnyk 6162 posts 24132 karma points MVP 8x admin c-trib
    Jul 05, 2017 @ 12:24
    Alex Skrypnyk
    0

    CurrentPage.uploadBanner - isn't perfect way to get image now, it's dynamic, and it's not recommended

    What is returning with this code : Umbraco.AssignedContentItem.GetPropertyValue

  • k 256 posts 654 karma points
    Jul 05, 2017 @ 12:45
    k
    0

    When I try to get the value from :

     var productImage = Umbraco.AssignedContentItem.GetPropertyValue<IPublishedContent>("uploadBanner");
    

    I get nothing.

  • Alex Skrypnyk 6162 posts 24132 karma points MVP 8x admin c-trib
    Jul 05, 2017 @ 13:43
    Alex Skrypnyk
    0

    And this one?

    var productImage = Umbraco.AssignedContentItem.GetPropertyValue("uploadBanner");

    Are Property Value Converters enabled?

    Umbraco 7.6?

  • k 256 posts 654 karma points
    Jul 06, 2017 @ 05:51
    k
    0

    Are Property Value Converters enabled? - yes

     <!-- Enables value converters for all built in property editors so that they return strongly typed object, recommended for use with Models Builder -->
    <EnablePropertyValueConverters>true</EnablePropertyValueConverters>
    

    When I used :

      var productImage = Umbraco.AssignedContentItem.GetPropertyValue("uploadBanner");
    

    I got the value of the image :) : <img src="/media/1001/afrasia-woman-tablet.jpg">

  • Alex Skrypnyk 6162 posts 24132 karma points MVP 8x admin c-trib
    Jul 06, 2017 @ 09:07
    Alex Skrypnyk
    0

    Hi Kusum

    What type of picker do you have on the page?

    Alex

  • k 256 posts 654 karma points
    Jul 06, 2017 @ 09:26
    k
    0

    I have used image cropper : Homepage - Upload banner - Image Cropper

    Should I use a media picker ?

  • Alan Mac Kenna 147 posts 405 karma points MVP c-trib
    Jul 06, 2017 @ 22:50
    Alan Mac Kenna
    0

    I think we're supposed to use Umbraco.Media() instead of Umbraco.Content() but aside from that I wonder is there an issue because of the core property value converters returning an ImageCropDataSet as opposed to an IPublishedContent which the extension method for GetResponsiveCropUrl() expects.

  • k 256 posts 654 karma points
    Jul 13, 2017 @ 10:07
    k
    0

    Hello,

    I am using a media picker now . But still the code does not work it gives me the error below :

    `Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Umbraco.Web.PublishedContentModels.Slider' does not contain a definition for 'GetResponsiveCropUrl'`
    

    I have used :

       @slider.GetResponsiveCropUrl("uploadBanner", "large")
    
  • Alex Skrypnyk 6162 posts 24132 karma points MVP 8x admin c-trib
    Jul 13, 2017 @ 12:10
    Alex Skrypnyk
    0

    Hi Kusum

    Show all your code, please.

    Thanks,

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft