Page MenuHomePhorge

PhabricatorImageDocumentEngine.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

PhabricatorImageDocumentEngine.php

<?php
final class PhabricatorImageDocumentEngine
extends PhabricatorDocumentEngine {
const ENGINEKEY = 'image';
protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) {
return 'fa-file-image-o';
}
protected function canRenderDocumentType(PhabricatorDocumentRef $ref) {
$file = $ref->getFile();
if ($file) {
return $file->isViewableImage();
}
$viewable_types = PhabricatorEnv::getEnvConfig('files.viewable-mime-types');
$viewable_types = array_keys($viewable_types);
$image_types = PhabricatorEnv::getEnvConfig('files.image-mime-types');
$image_types = array_keys($image_types);
return
$ref->hasAnyMimeType($viewable_types) &&
$ref->hasAnyMimeType($image_types);
}
protected function newDocumentContent(PhabricatorDocumentRef $ref) {
$file = $ref->getFile();
if ($file) {
$source_uri = $file->getViewURI();
} else {
// We could use a "data:" URI here. It's not yet clear if or when we'll
// have a ref but no backing file.
throw new PhutilMethodNotImplementedException();
}
$image = phutil_tag(
'img',
array(
'src' => $source_uri,
));
$linked_image = phutil_tag(
'a',
array(
'href' => $source_uri,
'rel' => 'noreferrer',
),
$image);
$container = phutil_tag(
'div',
array(
'class' => 'document-engine-image',
),
$linked_image);
return $container;
}
}

File Metadata

Mime Type
text/x-php
Expires
Wed, Jun 18, 10:09 AM (1 d, 23 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
228218
Default Alt Text
PhabricatorImageDocumentEngine.php (1 KB)

Event Timeline