Skip to content

Commit

Permalink
Fix dokufreaks#111 external images in links were broken
Browse files Browse the repository at this point in the history
This fixes the fix for internal relatively referenced images such that
it is really only applied to internal images and not external images.
  • Loading branch information
michitux committed Jun 4, 2013
1 parent 8b00ba4 commit 0c3e533
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions _test/media_linktitle_conversion.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function setUp() {
* [[test|{{dokuwiki.png}}]]
* [[#test|{{dokuwiki.png?w=200}}]]
* [[doku>test|{{dokuwiki.png?w=300}}]]
* [[test|{{https://www.dokuwiki.org/lib/tpl/dokuwiki/images/logo.png}}]]
EOF
, 'Test setup');
idx_addPage('wiki:included');
Expand All @@ -41,4 +42,9 @@ public function testInterWikiLinkTitleConversion() {
$html = p_wiki_xhtml('test:include');
$this->assertContains('src="'.ml('wiki:dokuwiki.png', array('w' => '300')).'"', $html);
}

public function testExternalMediaNotConverted() {
$html = p_wiki_xhtml('test:include');
$this->assertContains('src="'.ml('https://www.dokuwiki.org/lib/tpl/dokuwiki/images/logo.png').'"', $html);
}
}
2 changes: 1 addition & 1 deletion helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ function _convert_instructions(&$ins, $lvl, $page, $sect, $flags, $root_id, $inc

for($i=0; $i<$num; $i++) {
// adjust links with image titles
if (strpos($ins[$i][0], 'link') !== false && isset($ins[$i][1][1]) && is_array($ins[$i][1][1])) {
if (strpos($ins[$i][0], 'link') !== false && isset($ins[$i][1][1]) && is_array($ins[$i][1][1]) && $ins[$i][1][1]['type'] == 'internalmedia') {
// resolve relative ids, but without cleaning in order to preserve the name
$media_id = resolve_id($ns, $ins[$i][1][1]['src']);
// make sure that after resolving the link again it will be the same link
Expand Down

0 comments on commit 0c3e533

Please sign in to comment.