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. Attributes

Media

PreviousIconNextNumber

Last updated 6 months ago

Was this helpful?

{ label, help, name*, onSelect, attributes*, setAttributes* }
/**
 * @param {string} [label] - Component label.
 * @param {string} [help] - Component description.
 * @param {string} name - Attribute name.
 * @param {function} [onSelect] - Callback called when a media item is selected.
 * @param {object} attributes - Object containing block attributes.
 * @param {function} setAttributes - Function to set new block attribute values.
 */
block.json
"testMedia": {
	"type": "integer",
	"default": 0
}
index.js
import {
	TwebBlockMediaControl,
} from '@tigriweb/components/attributes';
index.js | edit()
<TwebBlockMediaControl
	label={ __('Media Label', 'your-theme-name') }
	help={ __('Media Description', 'your-theme-name') }
	name="testMedia"
	{...{ attributes, setAttributes }}
/>

TwebBlockMediaControl.Render

{ mediaId*, isBackground, className }
/**
 * @param {number} mediaId - The ID of the media item (default: 0).
 * @param {boolean} [isBackground] - Should media be rendered as a background image? (default: false).
 * @param {string} [className] - Additional CSS class name for the rendered component.
 */
index.js | save()
{ attributes.testMedia && (
	<TwebBlockMediaControl.Render
		mediaId={ attributes.testMedia }
		isBackground={ false }
		className="test-media"
	/>
) }

TwebBlockMediaControl