In this page

    Jekyll > Image manipulation

    Image manipulation

    Every image/file you upload in DatoCMS is stored on Imgix, a super-fast CDN optimized for image delivery.

    By adding some parameters to your image URL, you can enhance, resize and crop images, compress them and change format for better performance, create complex compositions, and extract useful metadata. The transformations happen on-the-fly and get cached on the CDN as well for future reuse.


    If you want to resize your image and convert it to JPG format, you just need to add ?w=800&h=600&fm=jpg at the end of the URL. The .url method makes it easy to generate these kind of URLs, by simply passing an hash of transformations as argument:

    blog_post.cover_image.url(w: 800, h: 600, fm: :jpg)
    # => ""

    Take a look at Imgix's Image API Reference page to see all the transformations available. Some trasformation names contain a dash (ie. border-radius), in this case this is the right syntax to use:

    blog_post.cover_image.url("border-radius" => 10);

    On top of all the features provided by Imgix you can also get a blurred-up SVG version of an image, for you to inline in the HTML of the page straight away. Then you can update the image with a high resolution image later in the user's browser, but avoiding reflows and only downloading the images that are actually necessary.

    Also you can learn more about this approach in our blog post about it.

    To get the blurred-up SVG you can use:

    blog_post.cover_image.lqip_data_url(w: 800, h: 600, fm: :jpg)