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

How to Enable Image upload option from our local gallery #243

Open
harshc99 opened this issue Oct 20, 2023 · 2 comments
Open

How to Enable Image upload option from our local gallery #243

harshc99 opened this issue Oct 20, 2023 · 2 comments

Comments

@harshc99
Copy link

hey Can anybody help me how should i upload image from my local machine gallery right now i can upload via Image URL but i want to upload the image from gallery please help me to figure it out and if possible share me the code

here is my code :

import React from "react";
import IsolatedBlockEditor, { EditorLoaded } from "@automattic/isolated-block-editor";
import reducer from "@wordpress/preferences/build-module/store/reducer";
import * as selectors from "@wordpress/preferences/build-module/store/selectors";
import * as actions from "@wordpress/preferences/build-module/store/actions";
import "./custom.css";
import "@automattic/isolated-block-editor/build-browser/core.css";
import { addFilter } from "@wordpress/hooks";
import { MediaUpload } from "@wordpress/media-utils";
import { mediaUpload } from "@wordpress/editor";

const CustomEditor = () => {
const settings = {
iso: {
moreMenu: false,
customStores: [
{
name: "core/preferences",
config: {
reducer: reducer,
selectors: selectors,
actions: actions,
},
},
],
},
};

settings.editor.mediaUpload = mediaUpload;

if (settings?.editor?.hasUploadPermissions) {
// Connect the media uploader if it's enabled
settings.editor.mediaUpload = mediaUpload;
addFilter(
"editor.MediaUpload",
"blocks-everywhere/media-upload",
() => MediaUpload
);
} else {
settings.editor.mediaUpload = null;
}

return (


Editor!


<IsolatedBlockEditor
style={{ height: "100%" }}
settings={settings}
onLoad={(parser, rawHandler) => {
console.log("parser: ", parser);
console.log("rawHandler: ", rawHandler);
}}
onSaveContent={(content) => {
console.log("onContentSave", content);
}}
onError={() => {
console.log("error");
}}
>
<EditorLoaded onLoaded={(container) => console.log(container)} />


);
};

export default CustomEditor;

image

@johngodley
Copy link
Member

The response in #242 still applies. Take a look at Blocks Everywhere to see how it is doing media uploads.

@harshc99
Copy link
Author

i already check out this Blocks Everywhere editor but i didnt find the proper solution please help me to figure this out and if possible can you share the code also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants