@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PHUIRemarkupImageView
4 extends AphrontView {
5
6 private $uri;
7 private $width;
8 private $height;
9 private $alt;
10 private $classes = array();
11
12 public function setURI($uri) {
13 $this->uri = $uri;
14 return $this;
15 }
16
17 public function getURI() {
18 return $this->uri;
19 }
20
21 public function setWidth($width) {
22 $this->width = $width;
23 return $this;
24 }
25
26 public function getWidth() {
27 return $this->width;
28 }
29
30 public function setHeight($height) {
31 $this->height = $height;
32 return $this;
33 }
34
35 public function getHeight() {
36 return $this->height;
37 }
38
39 public function setAlt($alt) {
40 $this->alt = $alt;
41 return $this;
42 }
43
44 public function getAlt() {
45 return $this->alt;
46 }
47
48 public function addClass($class) {
49 $this->classes[] = $class;
50 return $this;
51 }
52
53 public function render() {
54 $id = celerity_generate_unique_node_id();
55
56 Javelin::initBehavior(
57 'remarkup-load-image',
58 array(
59 'uri' => (string)$this->uri,
60 'imageID' => $id,
61 ));
62
63 $classes = null;
64 if ($this->classes) {
65 $classes = implode(' ', $this->classes);
66 }
67
68 return phutil_tag(
69 'img',
70 array(
71 'id' => $id,
72 'width' => $this->getWidth(),
73 'height' => $this->getHeight(),
74 'alt' => $this->getAlt(),
75 'class' => $classes,
76 ));
77 }
78
79}