Repository navigation
Adds explicit hero image support - #837
Merged
Merged
Conversation
- Add ImageUrl and ImageAlt properties to Entry for explicit hero image support - Update ProfilePost mapping to prefer explicit image fields, with fallback to in-content detection - Refine DasBlogSettings.RelativeToRoot to handle absolute, protocol-relative, and null/whitespace inputs correctly - Add comprehensive unit tests for RelativeToRoot - Normalize and trim image fields in mapping logic - Minor formatting improvements for consistency
Enables explicit selection, preview, and clearing of a hero image for blog posts, used for social previews. Adds HeroImageUrl and HeroImageAlt to PostViewModel and UI, introduces a modal picker for images from the post, server, or remote URLs, and updates controller, mapping, and persistence logic to support the new fields. Integrates with the Jodit editor for seamless image selection.
Added BlogDataService_HeroImageRoundTrip_Successful test to verify saving, updating, and clearing of ImageUrl and ImageAlt fields in blog entries using IBlogDataService. Ensures correct persistence and clearing of hero image properties.
Introduce ProfilePostHeroImageTests to verify mapping between Entry and PostViewModel for hero image fields, including handling of empty, null, and trimmed values. Tests utilize AutoMapper, Moq, and xUnit.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-class “hero image” fields for blog posts (URL + alt text) with editor UI support and end-to-end persistence, plus improved URL handling for absolute/protocol-relative paths.
Changes:
- Persist explicit hero image URL/alt on
Entry, map them throughPostViewModel, and round-trip viaBlogDataService. - Add editor UI (fields + modal picker) and JS to choose hero images from in-post images, server browser, or a remote URL.
- Enhance
DasBlogSettings.RelativeToRootto leave absolute and protocol-relative URLs unchanged, with new unit tests.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| source/newtelligence.DasBlog.Runtime/Entry.cs | Adds persisted hero image fields and includes them in change detection. |
| source/newtelligence.DasBlog.Runtime/BlogDataService.cs | Persists hero image fields during entry updates. |
| source/DasBlog.Web/wwwroot/js/dasblog-ui.js | Implements modal-based hero image picker UI behavior. |
| source/DasBlog.Web/Views/BlogPost/BlogPostFields.cshtml | Adds hero image inputs, preview, and modal launch/clear buttons. |
| source/DasBlog.Web/Views/BlogPost/_HeroImagePickerModal.cshtml | New modal markup for hero image selection sources. |
| source/DasBlog.Web/TagHelpers/RichEdit/JoditBuilder.cs | Exposes Jodit instance for the hero picker to reuse. |
| source/DasBlog.Web/Settings/DasBlogSettings.cs | Updates RelativeToRoot URL handling for absolute/protocol-relative inputs. |
| source/DasBlog.Web/Models/BlogViewModels/PostViewModel.cs | Adds bound hero image URL/alt properties. |
| source/DasBlog.Web/Mappers/ProfilePost.cs | Maps persisted hero image fields and resolves display image fallback. |
| source/DasBlog.Web/Controllers/DasBlogBaseController.cs | Minor formatting change (no behavior change). |
| source/DasBlog.Web/Controllers/BlogPostController.cs | Adds “clear hero image” submit action handling. |
| source/DasBlog.Tests/UnitTests/Settings/DasBlogSettingsTests.cs | Adds tests for absolute/protocol-relative/null/whitespace RelativeToRoot inputs. |
| source/DasBlog.Tests/UnitTests/Services/BlogDataServiceTest.cs | Adds persistence round-trip tests for hero image fields. |
| source/DasBlog.Tests/UnitTests/Mappers/ProfilePostHeroImageTests.cs | Adds mapping tests for hero image fields and trimming/nulling behavior. |
| source/DasBlog.Core/Common/Constants.cs | Adds BlogPostClearHeroImageAction constant. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Classification
New feature: Adds explicit hero image support for blog posts.
PR Summary
This PR introduces the ability to set, edit, and clear a dedicated hero image and alt text for blog posts, with UI enhancements and backend persistence. It also improves URL handling and adds related unit tests.