Skip to content

Adds explicit hero image support - #837

Merged
poppastring merged 5 commits into
mainfrom
explicit-default-images
May 18, 2026
Merged

poppastring merged 5 commits into
mainfrom
explicit-default-images

Conversation

@poppastring

Copy link
Copy Markdown
Owner

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.

  • PostViewModel.cs, Entry.cs: Add HeroImageUrl and HeroImageAlt properties and persist them.
  • BlogPostFields.cshtml, _HeroImagePickerModal.cshtml: Add UI for hero image selection and preview.
  • dasblog-ui.js: Implement modal-based hero image picker with in-post, server, and remote image support.
  • ProfilePost.cs, BlogPostController.cs, BlogDataService.cs: Update mapping, controller logic, and data service for hero image round-tripping and clearing.
  • DasBlogSettings.cs, DasBlogSettingsTests.cs: Enhance RelativeToRoot for absolute/protocol-relative URLs and add tests.

- 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 through PostViewModel, and round-trip via BlogDataService.
  • Add editor UI (fields + modal picker) and JS to choose hero images from in-post images, server browser, or a remote URL.
  • Enhance DasBlogSettings.RelativeToRoot to 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>
@poppastring
poppastring merged commit b04f4f0 into main May 18, 2026
3 checks passed
@poppastring
poppastring deleted the explicit-default-images branch May 18, 2026 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants