src/Plugin.php
private function _configureAssetIndexAttributes()
	{
		$newAttributes = [
			'provider' => "Provider",
		];

		Event::on(
			Asset::class,
			Asset::EVENT_REGISTER_HTML_ATTRIBUTES,
			function(RegisterElementHtmlAttributesEvent $event)
			{
				$embeddedAsset = $this->methods->getEmbeddedAsset($event->sender);

				if ($embeddedAsset && $embeddedAsset->code && $embeddedAsset->isSafe())
				{
					// Setting `null` actually adds the attribute, but doesn't include a value
					$event->htmlAttributes['data-embedded-asset'] = $embeddedAsset->aspectRatio;
				}
			}
		);

		Event::on(
			Asset::class,
			Asset::EVENT_REGISTER_TABLE_ATTRIBUTES,
			function(RegisterElementTableAttributesEvent $event) use($newAttributes)
			{
				foreach ($newAttributes as $attributeHandle => $attributeLabel)
				{
					$event->tableAttributes[$attributeHandle] = [
						'label' => Craft::t('embeddedassets', $attributeLabel),
					];
				}
			}
		);

		Event::on(
			Asset::class,
			Asset::EVENT_SET_TABLE_ATTRIBUTE_HTML,
			function(SetElementTableAttributeHtmlEvent $event) use($newAttributes)
			{
				// Prevent new table attributes from causing server errors
				if (array_key_exists($event->attribute, $newAttributes))
				{
					$event->html = '';
				}

				$embeddedAsset = $this->methods->getEmbeddedAsset($event->sender);
				$html = $embeddedAsset ? $this->_getTableAttributeHtml($embeddedAsset, $event->attribute) : null;

				if ($html !== null)
				{
					$event->html = $html;
				}
			}
		);
	}
private function _configureAssetIndexAttributes()
	{
		$newAttributes = [
			'provider' => "Provider",
		];

		Event::on(
			Asset::class,
			Asset::EVENT_REGISTER_HTML_ATTRIBUTES,
			function(RegisterElementHtmlAttributesEvent $event)
			{
				$embeddedAsset = $this->methods->getEmbeddedAsset($event->sender);

				if ($embeddedAsset && $embeddedAsset->code && $embeddedAsset->isSafe())
				{
					// Setting `null` actually adds the attribute, but doesn't include a value
					$event->htmlAttributes['data-embedded-asset'] = $embeddedAsset->aspectRatio;
				}
			}
		);

		Event::on(
			Asset::class,
			Asset::EVENT_REGISTER_TABLE_ATTRIBUTES,
			function(RegisterElementTableAttributesEvent $event) use($newAttributes)
			{
				foreach ($newAttributes as $attributeHandle => $attributeLabel)
				{
					$event->tableAttributes[$attributeHandle] = [
						'label' => Craft::t('embeddedassets', $attributeLabel),
					];
				}
			}
		);

		Event::on(
			Asset::class,
			Asset::EVENT_SET_TABLE_ATTRIBUTE_HTML,
			function(SetElementTableAttributeHtmlEvent $event) use($newAttributes)
			{
				// Prevent new table attributes from causing server errors
				if (array_key_exists($event->attribute, $newAttributes))
				{
					$event->html = '';
				}

				$embeddedAsset = $this->methods->getEmbeddedAsset($event->sender);
				$html = $embeddedAsset ? $this->_getTableAttributeHtml($embeddedAsset, $event->attribute) : null;

				if ($html !== null)
				{
					$event->html = $html;
				}
			}
		);
	}
private function _configureAssetIndexAttributes ( ) { $ newAttributes = [ 'provider' => "Provider" , ] ; Event :: on ( Asset :: class , Asset :: EVENT_REGISTER_HTML_ATTRIBUTES , function ( RegisterElementHtmlAttributesEvent $ event ) { $ embeddedAsset = $ this -> methods -> getEmbeddedAsset ( $ event -> sender ) ; if ( $ embeddedAsset && $ embeddedAsset -> code && $ embeddedAsset -> isSafe ( ) ) { // Setting `null` actually adds the attribute, but doesn't include a value $ event -> htmlAttributes [ 'data-embedded-asset' ] = $ embeddedAsset -> aspectRatio ; } } ) ; Event :: on ( Asset :: class , Asset :: EVENT_REGISTER_TABLE_ATTRIBUTES , function ( RegisterElementTableAttributesEvent $ event ) use ( $ newAttributes ) { foreach ( $ newAttributes as $ attributeHandle => $ attributeLabel ) { $ event -> tableAttributes [ $ attributeHandle ] = [ 'label' => Craft :: t ( 'embeddedassets' , $ attributeLabel ) , ] ; } } ) ; Event :: on ( Asset :: class , Asset :: EVENT_SET_TABLE_ATTRIBUTE_HTML , function ( SetElementTableAttributeHtmlEvent $ event ) use ( $ newAttributes ) { // Prevent new table attributes from causing server errors if ( array_key_exists ( $ event -> attribute , $ newAttributes ) ) { $ event -> html = '' ; } $ embeddedAsset = $ this -> methods -> getEmbeddedAsset ( $ event -> sender ) ; $ html = $ embeddedAsset ? $ this -> _getTableAttributeHtml ( $ embeddedAsset , $ event -> attribute ) : null ; if ( $ html !== null ) { $ event -> html = $ html ; } } ) ; }
Adds new and modifies existing asset table attributes in the control panel.
Adds new and modifies existing asset table attributes in the control panel .