where can i find media library component and call it in custom plugin? Im trying to pull image url from media library but cant find media component, if anyone knows where and how to use please let me know.
This topic has been created from a Discord post (1253689360801468537) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord
Hi, you can see how it was done in other plugins. Long story short, there is strapi/helper-plugin and you can use hook useLibrary
import React from "react";
import { prefixFileUrlWithBackendUrl, useLibrary } from "@strapi/helper-plugin";
import PropTypes from "prop-types";
const MediaLib = ({ isOpen, onChange, onToggle, editor, uploadConfig: { responsiveDimensions } }) => {
const { components } = useLibrary();
const MediaLibraryDialog = components["media-library"];
const handleChangeAssets = (assets) => {
let newValue = "";
assets.map(({ name, url, alt, formats, mime, width, height }) => {
if (mime.includes("image")) {
if (formats && responsiveDimensions) {
let set = "";
let keys = Object.keys(formats).sort((a, b) => formats[a].width - formats[b].width);
keys.map((k) => (set += prefixFileUrlWithBackendUrl(formats[k].url) + ` ${formats[k].width}w,`));
newValue += `<img src="${url}" alt="${alt}" width="${width}" height="${height}" srcset="${set}" />`;
} else {
newValue += `<img src="${url}" alt="${alt}" width="${width}" height="${height}" />`;
This file has been truncated. show original
<@1055738122060693575> are there any types for media library? in writing it in typescript. Thank you for your example it helped alot