All Projects → valdisiljuconoks → ImageResizer.Plugins.EPiServerBlobReader

valdisiljuconoks / ImageResizer.Plugins.EPiServerBlobReader

Licence: MIT license
EPiServer Blob provider for ImageResizer.Net

Programming Languages

C#
18002 projects
powershell
5483 projects

Projects that are alternatives of or similar to ImageResizer.Plugins.EPiServerBlobReader

seam-carving
An implementation of the seam carving algorithm, designed to resize images while preventing distortion.
Stars: ✭ 30 (+114.29%)
Mutual labels:  image-resizer
Lilliput
Resize images and animated GIFs in Go
Stars: ✭ 1,690 (+11971.43%)
Mutual labels:  image-resizer
Thumbnailator
Thumbnailator - a thumbnail generation library for Java
Stars: ✭ 3,845 (+27364.29%)
Mutual labels:  image-resizer
oc-imageresize-plugin
October Plugin - Image Resize
Stars: ✭ 13 (-7.14%)
Mutual labels:  image-resizer
oc-imageresizer-plugin
October CMS Plugin to resize and compress images
Stars: ✭ 44 (+214.29%)
Mutual labels:  image-resizer
imgwizard
Simple server for On-the-Fly image processing in Go
Stars: ✭ 51 (+264.29%)
Mutual labels:  image-resizer
reImage
Fast image resizing backend based on libvips, mozjpeg and pngquant
Stars: ✭ 107 (+664.29%)
Mutual labels:  image-resizer
rszr
Fast image resizer for Ruby
Stars: ✭ 21 (+50%)
Mutual labels:  image-resizer
Fast-Image-Resizer
Javafx application to resize images and add them into folders automatically.
Stars: ✭ 27 (+92.86%)
Mutual labels:  image-resizer

Build status

ImageResizer.Plugins.EPiServerBlobReader

Nothing much to describe here :) Just install NuGet package and it will register EPiServer Blob reader plugin for ImageResizer in order to serve and process images from EPiServer Media folders by ImageResizer.

Breaking Changes (starting from v6.0)

If you use fluent API to resize the image and pass in null, string.Empty or ContentReference.EmptyReference you will get ArgumentNullException exception.

Render Image in Markup

Most convenient way to render image in markup would be use HtmlHelper extension method:

@using ImageResizer.Plugins.EPiServer

<img src="@Html.ResizeImage(Model.CurrentPage.MainImage, 100, 100)" />

This will make sure that markup for visitors would be (assuming that image is png):

<img src="https://github.com/.../image.png?w=100&h=100">

And also for the edit mode it would be generated something like this:

<img src="https://github.com/.../image.png,,{CONTENT-ID}?epieditmode=False&w=100&h=100">

ResizeImage returns back UrlBuilder type, so you can fluently chain any additional paramters if needed:

<img src="@Html.ResizeImage(Model.CurrentPage.MainImage, 100, 150).Add("gradient", "true").Add("bgcolor", "red)" />

Render Image Markup (Fluent)

You can also use some basic fluent api support as well:

<img src="@Html.ResizeImage(CurrentPage.MainImage).Width(200)
                                                  .Height(200)
                                                  .Scale(ScaleMode.Both)
                                                  .FitMode(FitMode.Crop)" />

Render Image Markup with Fallback (Fluent)

If you need to fallback to other image in cases when given ContentReference is empty (and don't want to check for null or ContentReference.EmptyReference yourself) you can use resize image with fallback:

<img src="@Html.ResizeImageWithFallback(CurrentPage.MainImage, "/no-image.jpg").Width(200).Height(200).Scale(ScaleMode.Both).FitMode(FitMode.Crop)" />

Render Picture Element

This is pretty simple as well.

  1. We need to define picture profile. Profile is metadata how to render <picture> element.
public static PictureProfile SampleImage =
    new PictureProfile
    {
        SrcSetWidths = new[] { 480, 768, 992, 1200 },
        SrcSetSizes = new[]
        {
            "50vw",
        },
       DefaultWidth = 992
    };

Here we can specify couple of properties to customize element:

  • Source set sizes (SrcSetSizes) - this regulates image size for various media conditions.
  • Source set widths (SrcSetWidths) - this regulates various image sizes (resized by width specified here). Used to generate srcset attribute.
  • Default width (DefaultWidth) - what is default width of the image. This is for old-school browsers those have no clue about <picture> element existence.
  1. Call actual rendering method
@Html.ResizePicture(Model.CurrentPage.MainImage, PictureProfiles.SampleImage)
  1. Code above generates following markup:
<picture>
    <source sizes="50vw"
            srcset="/globalassets/batman.jpg?w=480 480w,
                    /globalassets/batman.jpg?w=768 768w,
                    /globalassets/batman.jpg?w=992 992w,
                    /globalassets/batman.jpg?w=1200 1200w">
    <img alt="" src="https://github.com/globalassets/batman.jpg?w=992">
</picture>

More info about how to render picture element - here.


Happy imaging!
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].