flammy / imagebox

This dokuwiki plugin displays captions in a box drawn around an image.
https://www.dokuwiki.org/plugin:imagebox
GNU General Public License v2.0
5 stars 7 forks source link

"Invalid link" from valid image #12

Closed iainhallam closed 7 years ago

iainhallam commented 7 years ago

I'm trying to put a box around an image that DokuWiki displays fine from Dropbox, but all I get is the text "Invalid link". I'm using the dynamic image syntax from DokuWiki's manual:

https://www.dokuwiki.org/images#dynamic_images

My resulting link is:

https://www.dropbox.com/sh/z4cxgwdkxwtr9q6/AADc1VVoM7xzKBgf2mQoErzda/BAC%20logo%20-%20black%20text.png?raw=1&.png?direct&300

Is ImageBox tripping up on the dynamic image parameter?

flammy commented 7 years ago

I just checked this in my test-setup and it worked for me:

[{{https://www.dropbox.com/sh/z4cxgwdkxwtr9q6/AADc1VVoM7xzKBgf2mQoErzda/BAC%20logo%20-%20black%20text.png?raw=1&.png?direct&300|description}}]

I tested this with

Please provide me some details about your installation and your utilization of the plugin (e.g. some link or snippet)

iainhallam commented 7 years ago

I'm also on DokuWIki 2017-02-19b with plugin version 2016-11-22.

Here's my entire markup block:

[{{https://www.dropbox.com/sh/z4cxgwdkxwtr9q6/AADc1VVoM7xzKBgf2mQoErzda/BAC%20logo%20-%20black%20text.png?raw=1&.png?direct&640|Full logo, black text\\ [[https://www.dropbox.com/sh/z4cxgwdkxwtr9q6/AACKMd7MG1Sr08FMUQxZ517ha/BAC%20logo%20-%20black%20text.svg?raw=1|Download SVG]]}}]

The HTML that results is:

<div class="thumb2 trien"><div class="thumbinner">Invalid Link<div class="thumbcaption" style="max-width: 634px"><div class="magnify"><a class="internal" title="Enlarge" href="/lib/exe/fetch.php?tok=be073d&amp;media=https%3A%2F%2Fwww.dropbox.com%2Fsh%2Fz4cxgwdkxwtr9q6%2FAADc1VVoM7xzKBgf2mQoErzda%2FBAC%2520logo%2520-%2520black%2520text.png%3Fraw%3D1%26.png"><img width="15" height="11" alt="" src="/lib/plugins/imagebox/magnify-clip.png"/></a></div>Full logo, black text<br/>
<a href="https://www.dropbox.com/sh/z4cxgwdkxwtr9q6/AACKMd7MG1Sr08FMUQxZ517ha/BAC%20logo%20-%20black%20text.svg?raw=1" class="urlextern" title="https://www.dropbox.com/sh/z4cxgwdkxwtr9q6/AACKMd7MG1Sr08FMUQxZ517ha/BAC%20logo%20-%20black%20text.svg?raw=1" rel="nofollow">Download SVG</a></div></div></div>

This is the first image on the page here: https://www.bristolacappella.co.uk/about/identity.

flammy commented 7 years ago

The message "Invalid Link" is shown because php was unable to fetch the image to determine its dimensions.

This can caused by the disabled php runtime configuration: allow_url_fopen.

Please check if your hoster supports enabling this configuration.

iainhallam commented 7 years ago

Checked the server and a phpinfo page shows that allow_url_fopen is On, though allow_url_include is Off.

ssahara commented 7 years ago

The SVG is a XML file and does not have a "size" in this context. The PHP function getImageSize() dose not support svg files, and returns false, resulted in "Invalid link" message in the imagebox plugin.

How about creating thumbnail in png file and provide download link for svg file?

[{{thumbnail.png?nolink&640|Full logo, black text\\ 
[[https://example.com/path/to/some.svg|Download SVG]]
}}]
iainhallam commented 7 years ago

If you check the full markup above, note that the image is a .png, and only the link in the description is to the SVG.

ssahara commented 7 years ago

@iainhallam , I have misunderstood the issue.

I tested following snippet you had shown in previous post:

[{{https://www.dropbox.com/sh/z4cxgwdkxwtr9q6/AADc1VVoM7xzKBgf2mQoErzda/BAC%20logo%20-%20black%20text.png?raw=1&.png?direct&640|Full logo, black text\\ [[https://www.dropbox.com/sh/z4cxgwdkxwtr9q6/AACKMd7MG1Sr08FMUQxZ517ha/BAC%20logo%20-%20black%20text.svg?raw=1|Download SVG]]}}]

and the png thumnail (bristol a cappella) successfully displayed without "Invalid link".

I guess failure of getImageSize() for remote file via https stream may cause "Invalid link" error. Since PHP 5.6.x, all encrypted client streams now enable peer verification by default. see http://docs.php.net/manual/pl/migration56.openssl.php for detail. Could you check whether your PHP supports OpenSSL? please check if "https" found in Registered PHP Streams field of phpinfo() output.

iainhallam commented 7 years ago

Yes, Registered PHP Streams is https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar, zip

flammy commented 7 years ago

@iainhallam Please put the following snippet on your server e.g. as test.php and open it with your browser and post your output here.

<?php

set_error_handler(function($errno, $errstr, $errfile, $errline, array $errcontext) {
    throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
});

try {
    $result = getImagesize('https://www.dropbox.com/sh/z4cxgwdkxwtr9q6/AADc1VVoM7xzKBgf2mQoErzda/BAC%20logo%20-%20black%20text.png?raw=1&.png');
    var_dump($result);
} catch (ErrorException $e) {
    echo $e->getMessage()."\n";
}
iainhallam commented 7 years ago

Thanks. That has revealed an outbound firewall, so I can debug that myself now.

iainhallam commented 7 years ago

Apologies for the bug report.