ueberdosis/tiptap

Html attributes not added to image when resize enabled

Geschlossen

#7.240 geöffnet am 18.11.2025

 (0 Kommentare) (0 Reaktionen) (1 zugewiesene Person)TypeScript (1.979 Forks)batch import
area: editorgood first issuestatus: triagetype: upstream

Repository-Metriken

Stars
 (23.454 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 4T 13h) (46 gemergte PRs in 30 T)

Beschreibung

Affected Packages

extension-image

Version(s)

3.10.7

Bug Description

Hi all, I am trying to add html attributes to an image I want to enable resize for.

The package versions are the following: react: 19.2.0 @tiptap/extension-image: 3.10.7 @tiptap/markdown: 3.10.7 @tiptap/react: 3.10.7 @tiptap/starter-kit: 3.10.7

Here is the code I use:

import Image from '@tiptap/extension-image'
import { Markdown } from '@tiptap/markdown'
import { EditorContent, useEditor } from '@tiptap/react'
import StarterKit from '@tiptap/starter-kit'

const MyEditor = () => {
  const imgContent = '![Image](https://placehold.co/600x400)'
  const editor = useEditor(
    {
      extensions: [
        Markdown,
        StarterKit.configure({
          codeBlock: false,
          code: false,
          horizontalRule: false,
          link: false,
          heading: {
            levels: [1, 2, 3]
          }
        }),
        Image.configure({
          inline: false,
          HTMLAttributes: {
            class: 'my-classname'
          },
          resize: {
            enabled: true,
            minWidth: 50,
            minHeight: 50,
            alwaysPreserveAspectRatio: true
          }
        })
      ],
      content: imgContent,
      editable: true,
      contentType: 'markdown'
    },
    [imgContent]
  )
  return <EditorContent editor={editor} />
}

The class attribute that I set to my-classname is not added on the img tag in the html

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

The class attribute should be added to the img tag in the html

Additional Context (Optional)

No response

Dependency Updates

  • Yes, I've updated all my dependencies.

Contributor Guide