TigriWeb Components
AttributesControlsMetaPrimitivesIntegrations
  • Table of Contents
  • Attributes
    • Checkbox
    • Color
    • ColorGradient
    • DateTime
    • Icon
    • Media
    • Number
    • PostType
    • PostTypeMultiple
    • Radio
    • Range
    • Select
    • Taxonomy
    • TaxonomyMultiple
    • Text
    • Textarea
    • Toggle
    • ToolbarButton
    • ToolbarGroup
  • Controls
    • AppenderButton
    • Media
    • RichHeading
    • RichText
  • Meta
    • Checkbox
    • Color
    • DateTime
    • Icon
    • Media
    • Number
    • PostType
    • PostTypeMultiple
    • Radio
    • Range
    • Select
    • Taxonomy
    • TaxonomyMultiple
    • Text
    • Textarea
    • Toggle
  • Primitives
    • HTML
    • SVG
  • Integrations
    • Enqueue SVG icons
    • Enqueue I18n strings
Powered by GitBook
On this page

Was this helpful?

  1. Controls

Media

PreviousAppenderButtonNextRichHeading

Last updated 6 months ago

Was this helpful?

{ name*, size, onSelect, customUrl, attributes*, setAttributes* }
/**
 * @param {string} name - Attribute name.
 * @param {string} [size] - Size of the image, e.g., 'thumbnail', 'medium', 'large'.
 * @param {function} [onSelect] - Callback called when a media item is selected.
 * @param {function} [customUrl] - Add a custom media URL button.
 * @param {object} attributes - Object containing block attributes.
 * @param {function} setAttributes - Function to set new block attribute values.
 */
block.json
"testMedia": {
	"type": "object",
	"default": {}
},
index.js
import {
	TwebBlockMedia,
} from '@tigriweb/components/controls';
index.js | edit()
<TwebBlockMedia
	name="testMedia"
	size="thumbnail"
	{...{ attributes, setAttributes }}
/>

TwebBlockMedia.Content

{ value* }
/**
 * @param {object} value - Object representing the media content.
 */
index.js | save()
{ attributes.testMedia.url && (
	<div className="custom-image">
		<TwebBlockMedia.Content
			value={ attributes.testMedia }
		/>
	</div>
) }

TwebBlockMedia