目前我使用 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">
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;
}