Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Blog and News - fixed problem with images

DanielŻuławskicbb776147a74
diff --git a/src/Web/Grand.Web/Views/Blog/BlogPost.cshtml b/src/Web/Grand.Web/Views/Blog/BlogPost.cshtml
index d8b722936..91f7c6456 100644
--- a/src/Web/Grand.Web/Views/Blog/BlogPost.cshtml
+++ b/src/Web/Grand.Web/Views/Blog/BlogPost.cshtml
@@ -1,12 +1,9 @@
@model BlogPostModel
@using Grand.Web.Models.Blogs;
@inject IPageHeadBuilder pagebuilder
-@inject IWorkContext workContext
@{
Layout = "_TwoColumns";
- var supportRtl = workContext.WorkingLanguage.Rtl;
-
//title
pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Title);
pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);
@@ -23,8 +20,12 @@
}
<div class="page blogpost-page">
@await Component.InvokeAsync("Widget", new { widgetZone = "blogpost_page_top", additionalData = Model.Id })
- <div class="card mt-3" @if (!string.IsNullOrEmpty(Model.PictureModel.ImageUrl)) { <text> img-src="@Model.PictureModel.ImageUrl" img-alt="@Model.PictureModel.AlternateText" </text> }>
+ <div class="card mt-3">
<div class="card-header">
+ @if (!string.IsNullOrEmpty(Model.PictureModel.ImageUrl))
+ {
+ <b-img-lazy class="img-fluid mb-3" src="@Model.PictureModel.ImageUrl" alt="@Model.PictureModel.AlternateText"></b-img-lazy>
+ }
<h1 class="h5 mb-0">
@Model.Title
</h1>
@@ -102,23 +103,15 @@
<div class="d-inline-flex w-100">
<h6 class="mb-0">@comment.CustomerName</h6>
<b-icon icon="calendar2-check" variant="info" class="mx-2"></b-icon>
- <small class="date d-flex text-muted">
- @if (supportRtl)
- {
- <span class="ml-1">@Loc["Blog.Comments.CreatedOn"]:</span>
- <span>@Convert.ToDateTime(comment.CreatedOn).ToString("tt HH:mm yyyy/MM/dd")</span>
- }
- else
- {
- <span class="mr-1">@Loc["Blog.Comments.CreatedOn"]:</span>
- <span>@comment.CreatedOn.ToString("g")</span>
- }
+ <small class="date text-muted">
+ <span>@Loc["Blog.Comments.CreatedOn"]:</span>
+ <span>@comment.CreatedOn.ToString("g")</span>
</small>
</div>
</div>
- <div class="col-12">
+ <div class="col-12 px-0">
<div class="row">
- <div class="col p-3">
+ <div class="col">
@comment.CommentText
</div>
</div>
@@ -131,4 +124,4 @@
}
@await Component.InvokeAsync("Widget", new { widgetZone = "blogpost_page_after_comments", additionalData = Model.Id })
@await Component.InvokeAsync("Widget", new { widgetZone = "blogpost_page_bottom", additionalData = Model.Id })
-</div>
+</div>
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/Blog/List.cshtml b/src/Web/Grand.Web/Views/Blog/List.cshtml
index 88cb1b38c..999674ce9 100644
--- a/src/Web/Grand.Web/Views/Blog/List.cshtml
+++ b/src/Web/Grand.Web/Views/Blog/List.cshtml
@@ -59,7 +59,11 @@
{
@await Component.InvokeAsync("Widget", new { widgetZone = "bloglist_page_before_post", additionalData = item.Id })
<div class="col-xl-6 col-12">
- <div class="card" @if (!string.IsNullOrEmpty(item.PictureModel.ImageUrl)) { <text>img-src="@item.PictureModel.ImageUrl" img-alt="@item.PictureModel.AlternateText"</text> }>
+ <div class="card">
+ @if (!string.IsNullOrEmpty(item.PictureModel.ImageUrl))
+ {
+ <b-img-lazy class="img-fluid card-img-top" src="@item.PictureModel.ImageUrl" alt="@item.PictureModel.AlternateText"></b-img-lazy>
+ }
<div class="card-header">
<h3 class="h5 mb-0">
<a href="@Url.RouteUrl("BlogPost", new { SeName = item.SeName })">
@@ -101,4 +105,4 @@
<page-navigation asp-query-param="pagenumber" asp-pagination="Model.PagingFilteringContext" />
@await Component.InvokeAsync("Widget", new { widgetZone = "bloglist_page_after_posts" })
-</div>
+</div>
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/News/List.cshtml b/src/Web/Grand.Web/Views/News/List.cshtml
index c127e1b8a..a78399745 100644
--- a/src/Web/Grand.Web/Views/News/List.cshtml
+++ b/src/Web/Grand.Web/Views/News/List.cshtml
@@ -14,11 +14,11 @@
{
<div class="col-xl-6 col-12">
<div class="card mb-3">
+ @if (!string.IsNullOrEmpty(item.PictureModel.ImageUrl))
+ {
+ <b-img-lazy class="img-fluid card-img-top" src="@item.PictureModel.ImageUrl" alt="@item.PictureModel.AlternateText"></b-img-lazy>
+ }
<div class="card-header">
- @if (!string.IsNullOrEmpty(item.PictureModel.ImageUrl))
- {
- <b-img-lazy class="img-fluid" src="@item.PictureModel.ImageUrl" alt="@item.PictureModel.AlternateText" />
- }
<h3 class="h5 mb-0">
<a href="@Url.RouteUrl("NewsItem", new { SeName = item.SeName })">
@item.Title
@@ -38,8 +38,8 @@
</div>
}
<page-navigation asp-query-param="pagenumber" asp-pagination="Model.PagingFilteringContext" />
-
+
@await Component.InvokeAsync("Widget", new { widgetZone = "newslist_page_after_items" })
</div>
-</div>
+</div>
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/News/NewsItem.cshtml b/src/Web/Grand.Web/Views/News/NewsItem.cshtml
index 038620545..a87e030cc 100644
--- a/src/Web/Grand.Web/Views/News/NewsItem.cshtml
+++ b/src/Web/Grand.Web/Views/News/NewsItem.cshtml
@@ -1,11 +1,8 @@
@model NewsItemModel
@inject IPageHeadBuilder pagebuilder
-@inject IWorkContext workContext
@{
Layout = "_TwoColumns";
- var supportRtl = workContext.WorkingLanguage.Rtl;
-
//title
pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Title);
pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);
@@ -16,7 +13,7 @@
<div class="card-header">
@if (!string.IsNullOrEmpty(Model.PictureModel.ImageUrl))
{
- <b-img-lazy class="img-fluid" src="@Model.PictureModel.ImageUrl" alt="@Model.PictureModel.AlternateText" />
+ <b-img-lazy class="img-fluid mb-3" src="@Model.PictureModel.ImageUrl" alt="@Model.PictureModel.AlternateText"></b-img-lazy>
}
<h1 class="h5 mb-0">
@Model.Title
@@ -82,23 +79,15 @@
<div class="d-inline-flex w-100">
<h6 class="mb-0">@comment.CustomerName</h6>
<b-icon icon="calendar2-check" variant="info" class="mx-2"></b-icon>
- <small class="date d-flex text-muted">
- @if (supportRtl)
- {
- <span class="ml-1">@Loc["News.Comments.CreatedOn"]:</span>
- <span>@Convert.ToDateTime(comment.CreatedOn).ToString("tt HH:mm yyyy/MM/dd")</span>
- }
- else
- {
- <span class="mr-1">@Loc["News.Comments.CreatedOn"]:</span>
- <span>@comment.CreatedOn.ToString("g")</span>
- }
+ <small class="date text-muted">
+ <span>@Loc["News.Comments.CreatedOn"]:</span>
+ <span>@comment.CreatedOn.ToString("g")</span>
</small>
</div>
</div>
- <div class="col-12">
+ <div class="col-12 px-0">
<div class="row">
- <div class="col p-3">
+ <div class="col">
<h5>@comment.CommentTitle</h5>
@comment.CommentText
</div>
@@ -111,4 +100,4 @@
}
}
@await Component.InvokeAsync("Widget", new { widgetZone = "newsitem_page_after_comments", additionalData = Model.Id })
-</div>
+</div>
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/Shared/Components/HomePageBlog/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/HomePageBlog/Default.cshtml
index 962ec6389..8cedba894 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/HomePageBlog/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/HomePageBlog/Default.cshtml
@@ -11,14 +11,18 @@
@foreach (var item in Model.Items)
{
- <div class="card" @if (item.PictureModel != null && !string.IsNullOrEmpty(item.PictureModel.ImageUrl)) { <text>img-src="@item.PictureModel.ImageUrl" img-alt="@item.PictureModel.AlternateText"</text> }>
+ <div class="card">
+ @if (item.PictureModel != null && !string.IsNullOrEmpty(item.PictureModel.ImageUrl))
+ {
+ <b-img-lazy class="img-fluid card-img-top" src="@item.PictureModel.ImageUrl" alt="@item.PictureModel.AlternateText"></b-img-lazy>
+ }
<div class="card-header">
<h3 class="h5 mb-0">
<b-link href="@Url.RouteUrl("BlogPost", new { SeName = item.SeName })">
@item.Title
</b-link>
</h3>
- </div>
+ </div>
<div class="card-body">
@Html.Raw(item.Short)
</div>
diff --git a/src/Web/Grand.Web/Views/Shared/Components/HomePageNews/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/HomePageNews/Default.cshtml
index 75f0295e2..1c7d6f2ae 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/HomePageNews/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/HomePageNews/Default.cshtml
@@ -9,14 +9,18 @@
@foreach (var item in Model.NewsItems)
{
- <div class="card" @if (item.PictureModel != null && !string.IsNullOrEmpty(item.PictureModel.ImageUrl)) { <text>img-src="@item.PictureModel.ImageUrl" img-alt="@item.PictureModel.AlternateText"</text> }>
+ <div class="card">
+ @if (!string.IsNullOrEmpty(item.PictureModel.ImageUrl))
+ {
+ <b-img-lazy class="img-fluid card-img-top" src="@item.PictureModel.ImageUrl" alt="@item.PictureModel.AlternateText"></b-img-lazy>
+ }
<div class="card-header">
<h3 class="h5 mb-0">
<b-link href="@Url.RouteUrl("NewsItem", new { SeName = item.SeName })">
@item.Title
</b-link>
</h3>
- </div>
+ </div>
<div class="card-body">
@Html.Raw(item.Short)
</div>
@@ -31,4 +35,4 @@
<div class="view-all text-center">
<a class="btn btn-outline-secondary" href="@Url.RouteUrl("NewsArchive")">@Loc["News.ViewAll"]</a>
</div>
-</div>
+</div>
\ No newline at end of file