Skip to content

896904: Added topic for load images in webp format #3206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions ej2-asp-core-mvc/carousel/how-to/load-images-in-webp-format.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
layout: post
title: Load webp format image in ##Platform_Name## Accordion Control | Syncfusion
description: Learn here all about how to load webp format image in Syncfusion ##Platform_Name## Accordion control of Syncfusion Essential JS 2 and more.
platform: ej2-asp-core-mvc
control: Load images in webp format
publishingplatform: ##Platform_Name##
documentation: ug
---


# Load webp format image in Carousel component

You can load the carousel image in the webp format, which aims to create smaller, better-looking images. Choosing webp as your image format can significantly improve your website's performance without sacrificing visual quality. webp images are significantly smaller in file size compared to formats like JPEG and PNG. This results in faster load times and less data usage. To achieve this, you can convert your image format to webp and pass them to Carousel items. The following sample illustrates how to load a carousel image in the webp format component.

{% if page.publishingplatform == "aspnet-core" %}

{% tabs %}
{% highlight cshtml tabtitle="CSHTML" %}
{% include code-snippet/carousel/how-to/carousel-webp/tagHelper %}
{% endhighlight %}
{% endtabs %}

{% elsif page.publishingplatform == "aspnet-mvc" %}

{% tabs %}
{% highlight razor tabtitle="CSHTML" %}
{% include code-snippet/carousel/how-to/carousel-webp/razor %}
{% endhighlight %}
{% highlight c# tabtitle="Wizard.cs" %}
{% include code-snippet/carousel/how-to/carousel-webp/carousel-webp.cs %}
{% endhighlight %}
{% endtabs %}
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public ActionResult Index()
{
return View();
}
55 changes: 55 additions & 0 deletions ej2-asp-core-mvc/code-snippet/carousel/how-to/carousel-webp/razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@using Syncfusion.EJ2.Navigations;

<div class="container">
<div class="control-container">
@(Html.EJS().Carousel("defaultCarousel").PartialVisible(true).Items(new List<CarouselItem> {
new CarouselItem { Template = "#itemTemplate1" },
new CarouselItem { Template = "#itemTemplate2" },
new CarouselItem { Template = "#itemTemplate3" },
})
.Render()
)
</div>
</div>
<script id="itemTemplate1" type="text/x-template">
<figure class="img-container">
<img src="https://www.gstatic.com/webp/gallery/1.webp" alt="Majestic Valley View" style="height:100%;width:100%;" />
<figcaption class="img-caption">Majestic Valley View</figcaption>
</figure>
</script>

<script id="itemTemplate1" type="text/x-template">
<figure class="img-container">
<img src="https://www.gstatic.com/webp/gallery/2.webp" alt="Thrilling Rapids Adventure" style="height:100%;width:100%;" />
<figcaption class="img-caption">Thrilling Rapids Adventure</figcaption>
</figure>
</script>

<script id="itemTemplate1" type="text/x-template">
<figure class="img-container">
<img src="https://www.gstatic.com/webp/gallery/3.webp" alt="Snowy Stroll" style="height:100%;width:100%;" />
<figcaption class="img-caption">Snowy Stroll</figcaption>
</figure>
</script>
<style>
.control-container {
background-color: #e5e5e5;
height: 360px;
margin: 0 auto;
width: 600px;
}

.img-container {
height: 100%;
margin: 0;
}

.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<div class="container">
<div class="control-container">
<ejs-carousel id="defaultCarousel">
<e-carousel-items>
<e-carousel-item template="#templateItem1"></e-carousel-item>
<e-carousel-item template="#templateItem2"></e-carousel-item>
<e-carousel-item template="#templateItem3"></e-carousel-item>
</e-carousel-items>
</ejs-carousel>
</div>
</div>
<script id="templateItem1" type="text/x-template">
<figure class="img-container">
<img src="https://www.gstatic.com/webp/gallery/1.webp" alt="Majestic Valley View" style="height:100%;width:100%;" />
<figcaption class="img-caption">Majestic Valley View</figcaption>
</figure>
</script>

<script id="templateItem2" type="text/x-template">
<figure class="img-container">
<img src="https://www.gstatic.com/webp/gallery/2.webp" alt="Thrilling Rapids Adventure" style="height:100%;width:100%;" />
<figcaption class="img-caption">Thrilling Rapids Adventure</figcaption>
</figure>
</script>

<script id="templateItem3" type="text/x-template">
<figure class="img-container">
<img src="https://www.gstatic.com/webp/gallery/3.webp" alt="Snowy Stroll" style="height:100%;width:100%;" />
<figcaption class="img-caption">Snowy Stroll</figcaption>
</figure>
</script>
<style>
.control-container {
background-color: #e5e5e5;
height: 360px;
margin: 0 auto;
width: 600px;
}

.img-container {
height: 100%;
margin: 0;
}

.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}

</style>
5 changes: 5 additions & 0 deletions ej2-asp-core-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,11 @@
<li><a href="/ej2-asp-core/carousel/navigators-and-indicators">Navigators and Indicators</a></li>
<li><a href="/ej2-asp-core/carousel/accessibility">Accessibility</a></li>
<li><a href="/ej2-asp-core/carousel/styles-and-appearance">Styles and Appearances</a></li>
<li>How To
<ul>
<li><a href="/ej2-asp-core/carousel/how-to/load-images-in-webp-format">Load images in webp format</a></li>
</ul>
</li>
<li>
<a href="/cr/aspnetcore-js2/Syncfusion.EJ2.Navigations.Carousel.html"> API Reference</a>
</li>
Expand Down
5 changes: 5 additions & 0 deletions ej2-asp-mvc-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,11 @@
<li><a href="/ej2-asp-mvc/carousel/navigators-and-indicators">Navigators and Indicators</a></li>
<li><a href="/ej2-asp-mvc/carousel/accessibility">Accessibility</a></li>
<li><a href="/ej2-asp-mvc/carousel/styles-and-appearance">Styles and Appearances</a></li>
<li>How To
<ul>
<li><a href="/ej2-asp-core/carousel/how-to/load-images-in-webp-format">Load images in webp format</a></li>
</ul>
</li>
<li>
<a href="/cr/aspnetmvc-js2/Syncfusion.EJ2.Navigations.Carousel.html"> API Reference</a>
</li>
Expand Down