Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image id fixes for request #2009

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions public/editor-client/src/media/addMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const addMedia: AddMediaData = {

wpMediaFrame.on("select", () => {
const attachment = wpMediaFrame.state().get("selection").first();
const { url, filename } = attachment.toJSON();
const { url } = attachment.toJSON();
const extension = getExtension(url);
const allExtensions = [
...acceptedExtensions,
Expand All @@ -57,7 +57,7 @@ export const addMedia: AddMediaData = {

getImageUid(attachment.get("id"))
.then((r) => {
res({ uid: r.uid, fileName: filename });
res({ uid: r.uid, fileName: "" });
})
.catch((r: unknown) => {
rej(t("failed to get attachment uid"));
Expand Down
6 changes: 3 additions & 3 deletions public/editor-client/src/media/addMediaGallery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
SelectionData
} from "../types/Media";
import { t } from "../utils/i18n";
import { uploadImage } from "./utils";
import { getImageUid } from "@/api";

export const addMediaGallery: AddMediaGallery = {
label: "Image",
Expand Down Expand Up @@ -53,8 +53,8 @@ export const addMediaGallery: AddMediaGallery = {
);

Promise.all(
images.map((file: ImageUpload) => {
return uploadImage(file);
images.map(({ id }: ImageUpload) => {
return getImageUid(String(id)).then(({ uid }) => ({ uid, fileName: "" }));
})
)
.then((uploadedImages: AddImageData[]) => {
Expand Down