Copied to clipboard

Flag this post as spam?

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


  • Matthew 138 posts 201 karma points
    Apr 24, 2014 @ 19:29
    Matthew
    0

    If no image cropper image, use a plain image

    Trolling for ideas while I work on this. I'm trying to get all img's to use the same var variation, ie: <img src="standardizedImgageVar" />, so I can re-use other bits of code in more places.

    So far in this project, different types of nodes may use different types of images: cropped; uploads; or media. For instance, a normal content page might have a banner crop, a plain content page might just use a plain media image, or a landing page might use an upload image.

    Rendering a crop vs media vs upload have all taken different variations in the img tag:

    crop = <img src="@pageVar.GetCropUrl(...)"/>;

    plain = <img src="imageVar.GetPropertyValue(...)" />;

    upload = <img src="@Umbraco.Field(...)" />.

    I'm thinking if I back the logic up a bit, I should be able to convert all these versions to a standardized var in a partial, before it gets to the img tags, then be able to just call the partial before a img and let it sort things out. The tag doesn't care how it gets there, it just wants a path and any particulars.

    I'm sure it wouldn't work in all cases but it seems like it might work in 90% of them. I see so many posts on how to render images, it almost seems like something that could be built in, maybe a 'yourPropertyAlias(yourCrop).uImage', stick it in any src="" and tada.

    Is this a good idea?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies