mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-22 16:33:00 +00:00
Implement short image links. Fixes #24.
This commit is contained in:
parent
93f91b40c7
commit
a075f8aa0a
3 changed files with 17 additions and 3 deletions
|
@ -4645,6 +4645,7 @@ class PeppermintParsedown extends ParsedownExtra
|
||||||
|
|
||||||
protected function inlineExtendedImage($fragment)
|
protected function inlineExtendedImage($fragment)
|
||||||
{
|
{
|
||||||
|
global $pageindex;
|
||||||
///^!\[(.*)\]\(([^ |)]+)\s*(?:\|([^|)]*)(?:\|([^)]*))?)?\)/
|
///^!\[(.*)\]\(([^ |)]+)\s*(?:\|([^|)]*)(?:\|([^)]*))?)?\)/
|
||||||
if(preg_match('/^!\[(.*)\]\(([^ |)]+)\s*(?:\|([^|)]*))?(?:\|([^|)]*))?(?:\|([^)]*))?\)/', $fragment["text"], $matches))
|
if(preg_match('/^!\[(.*)\]\(([^ |)]+)\s*(?:\|([^|)]*))?(?:\|([^|)]*))?(?:\|([^)]*))?\)/', $fragment["text"], $matches))
|
||||||
{
|
{
|
||||||
|
@ -4701,6 +4702,12 @@ class PeppermintParsedown extends ParsedownExtra
|
||||||
if($param3 !== false && strtolower(trim($param3)) == "caption")
|
if($param3 !== false && strtolower(trim($param3)) == "caption")
|
||||||
$imageCaption = true;
|
$imageCaption = true;
|
||||||
|
|
||||||
|
if(isset($pageindex->$imageUrl) and $pageindex->$imageUrl->uploadedfile)
|
||||||
|
{
|
||||||
|
// We have a short url! Expand it.
|
||||||
|
$imageUrl = "index.php?action=preview&size=" . max($imageSize["x"], $imageSize["y"]) ."&page=" . rawurlencode($imageUrl);
|
||||||
|
}
|
||||||
|
|
||||||
$style = "";
|
$style = "";
|
||||||
if($imageSize !== false)
|
if($imageSize !== false)
|
||||||
$style .= " max-width: " . $imageSize["x"] . "px; max-height: " . $imageSize["y"] . "px;";
|
$style .= " max-width: " . $imageSize["x"] . "px; max-height: " . $imageSize["y"] . "px;";
|
||||||
|
@ -4771,7 +4778,7 @@ class PeppermintParsedown extends ParsedownExtra
|
||||||
$result["element"],
|
$result["element"],
|
||||||
[
|
[
|
||||||
"name" => "figcaption",
|
"name" => "figcaption",
|
||||||
"text" => htmlentities($altText)
|
"text" => $altText
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
"attributes" => [
|
"attributes" => [
|
||||||
|
|
|
@ -194,7 +194,7 @@
|
||||||
"author": "Emanuil Rusev & Starbeamrainbowlabs",
|
"author": "Emanuil Rusev & Starbeamrainbowlabs",
|
||||||
"description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.",
|
"description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.",
|
||||||
"id": "parser-parsedown",
|
"id": "parser-parsedown",
|
||||||
"lastupdate": 1464550150,
|
"lastupdate": 1464601879,
|
||||||
"optional": false
|
"optional": false
|
||||||
}
|
}
|
||||||
]
|
]
|
|
@ -331,6 +331,7 @@ class PeppermintParsedown extends ParsedownExtra
|
||||||
|
|
||||||
protected function inlineExtendedImage($fragment)
|
protected function inlineExtendedImage($fragment)
|
||||||
{
|
{
|
||||||
|
global $pageindex;
|
||||||
///^!\[(.*)\]\(([^ |)]+)\s*(?:\|([^|)]*)(?:\|([^)]*))?)?\)/
|
///^!\[(.*)\]\(([^ |)]+)\s*(?:\|([^|)]*)(?:\|([^)]*))?)?\)/
|
||||||
if(preg_match('/^!\[(.*)\]\(([^ |)]+)\s*(?:\|([^|)]*))?(?:\|([^|)]*))?(?:\|([^)]*))?\)/', $fragment["text"], $matches))
|
if(preg_match('/^!\[(.*)\]\(([^ |)]+)\s*(?:\|([^|)]*))?(?:\|([^|)]*))?(?:\|([^)]*))?\)/', $fragment["text"], $matches))
|
||||||
{
|
{
|
||||||
|
@ -387,6 +388,12 @@ class PeppermintParsedown extends ParsedownExtra
|
||||||
if($param3 !== false && strtolower(trim($param3)) == "caption")
|
if($param3 !== false && strtolower(trim($param3)) == "caption")
|
||||||
$imageCaption = true;
|
$imageCaption = true;
|
||||||
|
|
||||||
|
if(isset($pageindex->$imageUrl) and $pageindex->$imageUrl->uploadedfile)
|
||||||
|
{
|
||||||
|
// We have a short url! Expand it.
|
||||||
|
$imageUrl = "index.php?action=preview&size=" . max($imageSize["x"], $imageSize["y"]) ."&page=" . rawurlencode($imageUrl);
|
||||||
|
}
|
||||||
|
|
||||||
$style = "";
|
$style = "";
|
||||||
if($imageSize !== false)
|
if($imageSize !== false)
|
||||||
$style .= " max-width: " . $imageSize["x"] . "px; max-height: " . $imageSize["y"] . "px;";
|
$style .= " max-width: " . $imageSize["x"] . "px; max-height: " . $imageSize["y"] . "px;";
|
||||||
|
@ -457,7 +464,7 @@ class PeppermintParsedown extends ParsedownExtra
|
||||||
$result["element"],
|
$result["element"],
|
||||||
[
|
[
|
||||||
"name" => "figcaption",
|
"name" => "figcaption",
|
||||||
"text" => htmlentities($altText)
|
"text" => $altText
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
"attributes" => [
|
"attributes" => [
|
||||||
|
|
Loading…
Reference in a new issue