sanity-plugin-markdown icon indicating copy to clipboard operation
sanity-plugin-markdown copied to clipboard

Don't add width param to image url, or make it configurable.

Open llibdude opened this issue 2 years ago • 2 comments

When uploading an image to markdown, the plugin adds ?w=450 to the end of the url. My content creators then need to manually strip that url param. In my case, if the width exists in the url, and in my site if I use that url in next/image, next/image will pull the 450 width version of the image, then scale it up to render it how i want. This creates very low resolution images.

I believe this the offending code https://github.com/sanity-io/sanity-plugin-markdown/blob/main/src/components/Editor.jsx#L60

Is it's purpose to render nicely in the preview? I would prefer it totally removed or at least allow configuration so that I can unset it.

In the meantime I am stripping this url param on my app side, which isn't the end of the world but not idea.

Thanks!

llibdude avatar Aug 19 '22 20:08 llibdude

Point up for this to be configurable

angelinekwan avatar Oct 28 '22 10:10 angelinekwan

You are able to do it with the following options now:

defineField({
  type: 'markdown',
  name: 'markdown',
  title: 'Markdown',
  options: {
    imageUrl: imageAsset => imageAsset.url
  }
});

ruchernchong avatar Jan 28 '23 16:01 ruchernchong