【发布时间】:2017-05-24 12:29:56
【问题描述】:
目前我使用 CodeIgniter 3.1.3 和 Parsedown / Markdown Guide
通过向下解析,我希望能够设置图像的宽度和高度
![enter image description][1]
[1]: http://www.example.com/image.png '100x200' <-- widthxheight
我尝试了上面的方法,但设置了图片标题。
输出将是
<img src="http://www.example.com/image.png" width="100" height="200" alt="enter image description">
Question 在 parsedown 库中有没有办法修改它所以可以得到 并设置图片的宽高?
protected function inlineImage($Excerpt)
{
if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
{
return;
}
$Excerpt['text']= substr($Excerpt['text'], 1);
$Link = $this->inlineLink($Excerpt);
if ($Link === null)
{
return;
}
$Inline = array(
'extent' => $Link['extent'] + 1,
'element' => array(
'name' => 'img',
'attributes' => array(
'src' => $Link['element']['attributes']['href'],
'alt' => $Link['element']['text'],
'width' => '',
'height' => ''
),
),
);
$Inline['element']['attributes'] += $Link['element']['attributes'];
unset($Inline['element']['attributes']['href']);
return $Inline;
}
【问题讨论】:
标签: php codeigniter parsedown