mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(catalog): avoid stretching unknown-size thumbnails
This commit is contained in:
@@ -271,6 +271,8 @@ describe('CatalogRow', () => {
|
||||
|
||||
expect(wrapper?.style.border).toContain('red');
|
||||
expect(frameImage).toBeTruthy();
|
||||
expect(frameImage?.getAttribute('width')).toBe('150');
|
||||
expect(frameImage?.getAttribute('height')).toBe('75');
|
||||
|
||||
await act(async () => {
|
||||
frameImage?.dispatchEvent(new Event('error', { bubbles: true }));
|
||||
@@ -322,6 +324,23 @@ describe('CatalogRow', () => {
|
||||
expect(container.querySelector<HTMLVideoElement>('video[src="https://example.com/file.mp4#t=0.001"]')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('does not force square dimensions on images when media metadata is missing', async () => {
|
||||
await act(async () => {
|
||||
root.render(
|
||||
createElement(CatalogPostMedia, {
|
||||
cid: 'image-post',
|
||||
commentMediaInfo: { type: 'image', url: 'https://example.com/file.png' },
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
const image = container.querySelector<HTMLImageElement>('img[src="https://example.com/file.png"]');
|
||||
|
||||
expect(image).toBeTruthy();
|
||||
expect(image?.getAttribute('width')).toBeNull();
|
||||
expect(image?.getAttribute('height')).toBeNull();
|
||||
});
|
||||
|
||||
it('renders media posts with board links, counts, and hover previews in all view', async () => {
|
||||
testState.directories = [{ address: 'music-posting.eth', features: { requirePostLinkIsMedia: true }, title: '/mu/ - Music' }];
|
||||
testState.linkCount = 2;
|
||||
|
||||
@@ -63,8 +63,9 @@ export const CatalogPostMedia = ({ cid, commentMediaInfo, linkWidth, linkHeight
|
||||
displayHeight = '54px';
|
||||
}
|
||||
|
||||
const numericWidth = parseInt(displayWidth) || undefined;
|
||||
const numericHeight = parseInt(displayHeight) || undefined;
|
||||
const hasKnownMediaDimensions = Boolean(linkWidth && linkHeight);
|
||||
const numericWidth = hasKnownMediaDimensions ? parseInt(displayWidth) || undefined : undefined;
|
||||
const numericHeight = hasKnownMediaDimensions ? parseInt(displayHeight) || undefined : undefined;
|
||||
|
||||
const maxWidth = imageSize === 'Large' ? '250px' : '150px';
|
||||
const maxHeight = imageSize === 'Large' ? '250px' : '150px';
|
||||
|
||||
Reference in New Issue
Block a user