Skip to content
This repository has been archived by the owner on Dec 23, 2023. It is now read-only.

Commit

Permalink
feat: add width, height, size, mime, responsive data to image tool
Browse files Browse the repository at this point in the history
This feature adds in the width, height, size, mime, and the responsive image data to the image tool. It saves all of that information to the database and is returned so that the user can use that information in their frontend.

This addresses several open and closed issues:
- #6
- #16
- #22 (duplicate of closed 6)
  • Loading branch information
jaskipper committed Feb 26, 2022
1 parent dcbe373 commit e07548c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions admin/src/components/medialib/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ const MediaLibComponent = ({isOpen, onChange, onToggle}) => {
};

const handleSelectAssets = files => {
console.log(files);
const formattedFiles = files.map(f => ({
alt: f.alternativeText || f.name,
url: prefixFileUrlWithBackendUrl(f.url),
width: f.width,
height: f.height,
size: f.size,
mime: f.mime,
formats: f.formats
}));
onChange(formattedFiles);
};
Expand Down
9 changes: 8 additions & 1 deletion admin/src/components/medialib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ export const getToggleFunc = ({openStateSetter, indexStateSetter}) => {
export const changeFunc = ({indexStateSetter, editor, data, index}) => {
let insertedBlocksCount = 0;
data.forEach((entry) => {

console.log(entry);
if (!entry.mime.includes("image")) {
return;
}

const newBlockType = "image";
const newBlockData = {
file: {
url: entry.url.replace(window.location.origin, "")
url: entry.url.replace(window.location.origin, ""),
mime: entry.mime,
height: entry.height,
width: entry.width,
size: entry.size,
responsiveUrls: [entry.formats]
},
caption: "",
withBorder: false,
Expand Down

0 comments on commit e07548c

Please sign in to comment.