Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P1158
<img> support in remarkup
Active
Public
Actions
Authored by
swisspol
on May 22 2014, 3:36 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F158909: img_support_in_remarkup
May 22 2014, 3:36 PM
2014-05-22 15:36:23 (UTC+0)
Subscribers
srijan
Tokens
"Love" token, awarded by jithinvmohan.
<?php
final
class
CustomInlineImageRule
extends
PhabricatorRemarkupCustomInlineRule
{
public
function
getPriority
()
{
return
200.0
;
// Must be lower than 300 to over URL detection
}
public
function
apply
(
$text
)
{
return
preg_replace_callback
(
'(<img (.*?)>)s'
,
array
(
$this
,
'markupInlineImageBlock'
),
$text
);
}
public
function
markupInlineImageBlock
(
$matches
)
{
$engine
=
$this
->
getEngine
();
$text
=
$matches
[
1
];
$element
=
new
SimpleXMLElement
(
"<element $text />"
);
$attributes
=
array
();
foreach
(
$element
->
attributes
()
as
$k
=>
$v
)
{
$attributes
[
$k
]
=
$v
;
}
$source_body
=
phutil_tag
(
'img'
,
$attributes
);
return
$engine
->
storeText
(
$source_body
);
}
}
Event Timeline
swisspol
edited the content of this paste.
(Show Details)
May 22 2014, 3:36 PM
2014-05-22 15:36:23 (UTC+0)
swisspol
changed the title of this paste from untitled to
<img> support in remarkup
.
swisspol
updated the paste's language from
autodetect
to
autodetect
.
•
jithinvmohan
awarded a token.
Oct 15 2015, 5:16 PM
2015-10-15 17:16:01 (UTC+0)
srijan
added a subscriber:
srijan
.
Oct 27 2015, 5:01 AM
2015-10-27 05:01:29 (UTC+0)
Log In to Comment