Update ImageSharp.Web v2, Lombiq Helpful Libraries - Resource Management for Orchard Core - This week in Orchard (19/05/2022)

Gábor Domonkos's avatar
This week in Orchard, Theme, Resource manifest

Updating ImageSharp.Web v2, removing pagenum=1 from the 1 pager link to improve SEO, adding OnMessageSendingAsync() protected method and news and updates around the Lombiq Helpful Libraries. Check out our current post to read about the details!

Orchard Core updates

Update ImageSharp.Web v2

ImageSharp is a new, fully-featured, fully managed, cross-platform, 2D graphics library. Designed to simplify image processing, ImageSharp brings you an incredibly powerful yet beautifully simple API.

ImageSharp is designed from the ground up to be flexible and extensible. The library provides API endpoints for common image processing operations and the building blocks to allow for the development of additional operations.

ImageSharp.Web is a high-performance ASP.NET Core Middleware built on top of ImageSharp that allows the processing and caching of image requests via a simple API. ImageSharp.Web provides API endpoints for common image processing operations and the building blocks to allow for the development of additional extensions to add image sources, caching mechanisms, or even your own processing API. A few weeks ago ImageSharp.Web v2 had been released, and now Orchard is using the latest version of ImageSharp thanks to Dean Marcussen. ImageSharp is used in Orchard Core when you would like to work with Media Profiles or when you work with images (like setting up a crop point) from the Media Library using the Media Field.

Remove pagenum=1 from the "1" pager link to improve SEO

There's a minor SEO problem with the pager when pagenum=1. Since the content of pagenum=1 is identical to the page where the pagenum parameter is absent, SEO audit tools want a canonical URL to be specified. Though arguably, the pagenum parameter should just be removed when the value is 1.

Steps to reproduce the behavior:

  1. Set up your site with the Blog recipe.
  2. Navigate to Configuration -> Settings -> General and set the Page size to 1.
  3. View the content items and observe the pager behavior.

The expectation would be the pagenum parameter to be removed for the 1 link like it is for the < and << links.

Issue with displaying the pagenum parameter

From now, you will not find pagenum=1 when you would like to navigate to the first page of your lists, even when you are hovering over the list item that contains 1 in your pager.

Remove pagenum 1 from the pager

Adding OnMessageSendingAsync() protected method

There is a new protected virtual method called OnMessageSendingAsync, which is called before you want to send a new email using the STMP service. Now you can define how to configure the SMTP client before sending your message.

The new OnMessageSendingAsync method

News from the community

Lombiq Helpful Libraries - Resource Management for Orchard Core

The resource filter makes it possible to include resources automatically based on the current context. E.g., inject home page styling only when the home page is being loaded.,

Let's see a quick and simple sample about how you can use it and, what can you do exactly with this filter! Last week we mentioned that our Base Theme for Orchard Core is released, which contains all the foundations to build Orchard themes efficiently with included detailed samples.

If you want to quickly try out this project and see it in action, clone our Open-Source Orchard Core Extensions full Orchard Core solution and also see our other useful Orchard Core-related open-source projects! We will clone the Lombiq's Open-Source Orchard Core Extensions repository for this demo as well.

We will set up our site using the Blog recipe. After that, you can navigate to Design -> Themes and enable the Lombiq Base Theme and Lombiq Base Theme - Samples themes. You can also make the Samples one as the current site theme. Don't forget to enable the Lombiq Helpful Extensions - Helpful Widgets feature from Configuration -> Features.

The detail view of a blog post using the Lombiq Base Theme for Orchard Core

And now, you can go to the home page of your site and open the predefined blog post that comes from the recipe. You will see that our theme is applied with our stylesheets too, which will apply a different look when the site renders the detailed view of a blog post content item. And here comes the resource filters.

To add resource filters the IResourceFilterProvider interface needs to be implemented, and the registration needs to be added to the service collection as well.

Adding resource filters

As you can see here, we used the Always, and WhenContentType methods to define when to inject the stylesheets that we registered using the RegisterStylesheet method. We also have a RegisterFootScript and a RegisterHeadScript method to register scripts that will be displayed in the head or at the foot of the page.

If you always want to inject the resource named Site, you can use the Always method. And if you only want to inject the resource named BlogPost when we display the detail view of the BlogPost content type, use the WhenContentType method and provide the BlogPost as the name of the content type.

And don't forget to activate the resource filter middleware by adding app.UseResourceFilters() to the Configure method of the Startup file located in a common module or the web project. E.g.:

public override void Configure(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider)

If you check out the ResourceFilterBuilder.cs (right side of the screen) you will find any other helpful methods that can be used to conditionally inject resources. Like the WhenHomePage and the WhenPathStartsWith ones, which have self-describing names.

For more information, don't forget to check out the readme file about Resource Management.

Orchard Dojo Newsletter

Lombiq's Orchard Dojo Newsletter has 253 subscribers! We have started this newsletter to inform the community around Orchard with the latest news about the platform. By subscribing to this newsletter, you will get an e-mail whenever a new post is published to Orchard Dojo, including This week in Orchard of course.

Do you know of other Orchard enthusiasts who you think would like to read our weekly articles? Tell them to subscribe here!

If you are interested in more news around Orchard and the details of the topics above, don't forget to check out the recording of this Orchard meeting!

No Comments

Add a Comment