Skip to content

Cropped Image-fix in addImagesCropDialog - #1466

Open
Takitxt wants to merge 3 commits into
AOSSIE-Org:mainfrom
Takitxt:add-image-dialog-fix
Open

Cropped Image-fix in addImagesCropDialog#1466
Takitxt wants to merge 3 commits into
AOSSIE-Org:mainfrom
Takitxt:add-image-dialog-fix

Conversation

@Takitxt

@Takitxt Takitxt commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Addressed Issues:

Fixes #1459 : Images appear cropped in the "Add Image" window when adding images to an album.

Screenshots/Recordings:

PictoPy Before:

631599087-26e43e8f-f2c5-45fd-95b6-70db8b850195.mov

PictoPy After:

Portraits:
Screenshot 2026-08-06 at 2 33 53 PM

Landscapes:
Screenshot 2026-08-06 at 9 27 05 AM

Additional Notes:

File Changed: 1

frontend/src/components/Albums/addImagesToAlbumDialog:
A little bit of css changes:

{filteredImages.map((image) => (
                  <div
                    key={image.id}
                    className="group hover:border-primary bg-muted relative aspect-square cursor-pointer overflow-hidden rounded-md border-2 transition-all"
                    style={{
                      borderColor: selectedImages.has(image.id)
                        ? 'hsl(var(--primary))'
                        : 'transparent',
                    }}
                    onClick={() => handleImageToggle(image.id)}
                  >
                    <div className="bg-muted flex h-full w-full items-center justify-center">
                      <img
                        src={convertFileSrc(image.thumbnailPath)}
                        alt={image.path.split('/').pop() || ''}
                        loading="lazy"
                        className="max-h-full max-w-full object-contain transition-transform group-hover:scale-105"
                        onError={(e) => {
                          const img = e.target as HTMLImageElement;
                          img.onerror = null;
                          const placeholder = window.matchMedia(
                            '(prefers-color-scheme: dark)',
                          ).matches
                            ? '/placeholder-album.svg'
                            : '/placeholder-album-light.svg';
                          img.src = placeholder;
                        }}
                      />
                    </div>

                    {selectedImages.has(image.id) && (
                      <div className="bg-primary/20 absolute inset-0 flex items-center justify-center">
                        <div className="bg-primary flex h-8 w-8 items-center justify-center rounded-full">
                          <Check className="text-primary-foreground h-5 w-5" />
                        </div>
                      </div>
                    )}
                  </div>
                ))}
              </div>
            )}

Fixes:

  • This shows the whole image to the user that he is adding and fixes the crop issue.

One Flaw:

The landscape pictures have a little bit of a blank space on the up and down side of the photo box, but if i fix it , it will end up in the crop. It is possible but it will cut a little bit part from landscape images, currently it shows the whole image.
(if you want me to fix it i can, but i kind of prefer the current version)

AI Usage Disclosure:

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.

Check one of the checkboxes below:

  • This PR does not contain AI-generated code at all.
  • This PR contains AI-generated code. I have read the AI Usage Policy and this PR complies with this policy. I have tested the code locally and I am responsible for it.

I have used the following AI models and tools: Claude Sonnet - 5

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contribution Guidelines
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
  • I have filled this PR template completely and carefully, and I understand that my PR may be closed without review otherwise.

Summary by CodeRabbit

  • Style
    • Improved album image thumbnails with consistent muted containers and better aspect-ratio handling.
    • Added a subtle hover zoom effect for easier image browsing.
    • Added descriptive alternative text based on image filenames.
    • Added lazy loading to improve image browsing performance.
    • Preserved theme-specific placeholders when thumbnails fail to load.
    • Improved visual feedback for selected images.

@github-actions github-actions Bot added UI bug Something isn't working labels Aug 6, 2026
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3edafe23-46d0-4b4b-b6e9-ca7e80e26d68

📥 Commits

Reviewing files that changed from the base of the PR and between 5eb7aac and 34e885d.

📒 Files selected for processing (1)
  • frontend/src/components/Albums/AddImagesToAlbumDialog.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/components/Albums/AddImagesToAlbumDialog.tsx

Walkthrough

The album image grid preserves image aspect ratios, uses theme-aware placeholders, lazy-loads thumbnails, adds hover scaling, provides filename-based alt text, and applies conditional selection borders.

Changes

Album thumbnail UI

Layer / File(s) Summary
Thumbnail presentation
frontend/src/components/Albums/AddImagesToAlbumDialog.tsx
The dialog selects a placeholder from the active theme. Thumbnail containers use muted styling and conditional selection borders. Images use object-contain, lazy loading, filename-based alt text, hover scaling, and the theme-derived fallback.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: TypeScript/JavaScript

Poem

I’m a rabbit with thumbnails neat,
Full images now look complete.
They fit, they load, they softly scale,
Theme-safe fallbacks guard the trail.
Selection borders mark each tale.

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR also adds lazy loading, hover scaling, alt text, theme placeholders, and container styling beyond the linked issue's crop fix. Move unrelated thumbnail UX, accessibility, and performance changes into a separate PR, or document their necessity in the linked issue.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the cropped-image fix in the add-image dialog, despite using an imprecise component name.
Linked Issues check ✅ Passed The changes use contain-style rendering and preserve image proportions, meeting the complete-preview requirements in issue #1459.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🧹 Nitpick comments (1)
frontend/src/components/Albums/AddImagesToAlbumDialog.tsx (1)

152-154: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the typed image target.

Because the handler is attached to the <img>, e.currentTarget provides the typed HTMLImageElement. Replace e.target as HTMLImageElement with e.currentTarget to remove the unnecessary assertion.

Proposed fix
-                          const img = e.target as HTMLImageElement;
+                          const img = e.currentTarget;

As per coding guidelines: frontend/src/**/*.{ts,tsx} says not to use as to silence genuine type errors.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/components/Albums/AddImagesToAlbumDialog.tsx` around lines 152 -
154, Update the onError handler on the image element to assign e.currentTarget
directly to img instead of casting e.target to HTMLImageElement, preserving the
existing img.onerror behavior without using a type assertion.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/src/components/Albums/AddImagesToAlbumDialog.tsx`:
- Around line 138-143: Update the thumbnail element in AddImagesToAlbumDialog to
remove the inline borderColor style and conditionally apply border-primary or
border-transparent through the existing cn() utility based on
selectedImages.has(image.id), preserving hover:border-primary for unselected
thumbnails.
- Around line 155-160: Update the fallback placeholder selection in the
image-loading logic of AddImagesToAlbumDialog to use the application theme from
useTheme(), matching AlbumCard, instead of
window.matchMedia('prefers-color-scheme'). Reuse the existing theme-derived
value or shared placeholder helper and preserve the dark/light placeholder
mapping.
- Line 138: Remove the hover scale styling from the preview image container in
AddImagesToAlbumDialog, specifically the group-hover:scale-105 behavior, while
preserving the aspect-square layout and other existing thumbnail styles.

---

Nitpick comments:
In `@frontend/src/components/Albums/AddImagesToAlbumDialog.tsx`:
- Around line 152-154: Update the onError handler on the image element to assign
e.currentTarget directly to img instead of casting e.target to HTMLImageElement,
preserving the existing img.onerror behavior without using a type assertion.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b6f575c7-543e-49ca-bb8d-888a6abf57fe

📥 Commits

Reviewing files that changed from the base of the PR and between 5b4c41d and d7ae9dd.

📒 Files selected for processing (1)
  • frontend/src/components/Albums/AddImagesToAlbumDialog.tsx

Comment thread frontend/src/components/Albums/AddImagesToAlbumDialog.tsx Outdated
Comment thread frontend/src/components/Albums/AddImagesToAlbumDialog.tsx Outdated
Comment thread frontend/src/components/Albums/AddImagesToAlbumDialog.tsx Outdated
@Takitxt

Takitxt commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@rohan-pandeyy can you please review this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG:Images appear cropped in the "Add Image" window when adding images to an album.

1 participant