Skip to content

Commit

Permalink
imageViewer updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasminDreasond committed Jul 29, 2024
1 parent a01ef7e commit b2b5a1e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/app/molecules/media/Media.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function Image({
imageLoaded = true;
const img = $(event.target);
const imgAction = () => {
imageViewer({ lightbox, imgQuery: img, name, url });
imageViewer({ lightbox, imgQuery: img, name });
};

img.off('click', imgAction);
Expand Down
4 changes: 0 additions & 4 deletions src/app/organisms/profile-viewer/ProfileViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,7 @@ function ProfileViewer() {
onClose: reopenProfile,
imgQuery: img,
name: username,
url: img.attr('src'),
originalUrl: newAvatar,
readMime: true,
});
}
};
Expand Down Expand Up @@ -682,9 +680,7 @@ function ProfileViewer() {
lightbox,
imgQuery: img,
name: userId,
url: img.attr('src'),
originalUrl: newAvatar,
readMime: true,
});
}
};
Expand Down
2 changes: 0 additions & 2 deletions src/app/organisms/profile-viewer/RoomViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ function RoomViewer() {
lightbox,
imgQuery: img,
name: username,
url: img.attr('src'),
originalUrl: newAvatar,
readMime: true,
});
}
};
Expand Down
11 changes: 7 additions & 4 deletions src/util/imageViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export default function imageViewer(data) {
// Read Image Tag
const img = data.imgQuery.get(0);
if (img) {
// File Url
const url = data.imgQuery.attr('src');

// Get Mime
let filename = data.name;

Expand Down Expand Up @@ -41,7 +44,7 @@ export default function imageViewer(data) {
const options = {
dataSource: [
{
src: data.url,
src: url,
alt: filename,
width: imgData.width,
height: imgData.height,
Expand All @@ -67,7 +70,7 @@ export default function imageViewer(data) {
isButton: true,
html: '<i class="fa-solid fa-arrow-up-right-from-square pswp__icn" height="32" width="32"></i>',
onClick: () => {
window.open(data.url, '_blank').focus();
window.open(url, '_blank').focus();
},
});
}
Expand All @@ -79,7 +82,7 @@ export default function imageViewer(data) {
isButton: true,
html: '<i class="fa-solid fa-floppy-disk pswp__icn" height="32" width="32"></i>',
onClick: () => {
FileSaver.saveAs(data.url, filename);
FileSaver.saveAs(url, filename);
},
});

Expand All @@ -90,7 +93,7 @@ export default function imageViewer(data) {
isButton: true,
html: '<i class="fa-solid fa-circle-info pswp__icn" height="32" width="32"></i>',
onClick: () => {
fetchFn(data.url)
fetchFn(url)
.then((res) => res.arrayBuffer())
.then(async (body) => {
const newTags = await ExifReader.load(body, {
Expand Down
2 changes: 0 additions & 2 deletions src/util/libs/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ export function openOnGallery(imgUrl, fileName /* urlRevoke = false */) {
lightbox: null,
imgQuery: $(img),
name: fileName,
url: imgUrl,
readMime: false,
}).then((/* pswp */) => {
/* pswp.on('close', () => {
pswp.destroy();
Expand Down

0 comments on commit b2b5a1e

Please sign in to comment.