Craft\EmbeddedAssetsPlugin::getAssetTableAttributeHtml PHP Method

getAssetTableAttributeHtml() public method

Hook for formatting the HTML for embedded asset attributes in the Assets manager.
public getAssetTableAttributeHtml ( $element, $attribute ) : null | string
$element
$attribute
return null | string
    public function getAssetTableAttributeHtml($element, $attribute)
    {
        if ($element instanceof AssetFileModel) {
            $embed = craft()->embeddedAssets->getEmbeddedAsset($element);
            if ($embed) {
                switch ($attribute) {
                    case 'filename':
                        $stripProtocol = preg_replace('/^((https?:\\/\\/)|(\\/\\/))/', '', $embed->url);
                        $stripWWW = preg_replace('/^www\\./', '', $stripProtocol);
                        $trimmedUrl = mb_strimwidth($stripWWW, 0, 50, '...');
                        return HtmlHelper::encodeParams('<a href="{url}" target="_blank" style="word-break: break-word;">{name}</a>', array('url' => $embed->url, 'name' => $trimmedUrl));
                    case 'provider':
                        return HtmlHelper::encodeParams('<a href="{url}" target="_blank" data-provider="{data}">{name}</a>', array('url' => $embed->providerUrl, 'data' => StringHelper::toCamelCase($embed->providerName), 'name' => $embed->providerName));
                    case 'author':
                        return HtmlHelper::encodeParams('<a href="{url}" target="_blank">{name}</a>', array('url' => $embed->authorUrl, 'name' => $embed->authorName));
                    case 'size':
                        return '';
                    case 'kind':
                        switch ($embed->type) {
                            case 'photo':
                                return Craft::t("Embedded Image");
                            case 'video':
                                return Craft::t("Embedded Video");
                            case 'link':
                                return Craft::t("Embedded Link");
                        }
                        return Craft::t("Embedded Media");
                    case 'imageSize':
                        if ($embed->type == 'image') {
                            $width = $embed->width;
                            $height = $embed->height;
                            if ($width && $height) {
                                return $width . ' &times; ' . $height;
                            } else {
                                return null;
                            }
                        } else {
                            return '';
                        }
                    case 'width':
                    case 'height':
                        if ($embed->type == 'image') {
                            $size = $embed->{$attribute};
                            return $size ? $size . 'px' : null;
                        } else {
                            return '';
                        }
                }
            }
        }
        switch ($attribute) {
            case 'provider':
            case 'author':
                return '';
        }
        return null;
    }