Discussion:
Can I display a local imaeg file in a DokuWiki page?
Chris G
2010-02-07 15:16:53 UTC
Permalink
I am running DokuWiki for personal use on my desktop machine (xubuntu
9.10) and would like to display image files stored in the local file
system in DokuWiki but at the moment I can't see any way to do this.

Am I missing something?

The {{xxx:yyy:image.png}} syntax expects the image file to be in a
namespace, and it isn't. The alternative URL syntax only seems to
recognise http: URLs and the images aren't served by apache.

I've tried a file URL:-
{{file:///home/chris/pictures/2000s/2009/09 Sept 6-13 - Sarthe/DSCF2019.JPG}}

but DukuWiki just turns this into one long filename with the / and
spaces turned into underscores.

I don't really want to copy the images into DikuWiki, a waste of space
and changes I make to the 'master' image won't get propogated.
--
Chris Green
--
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist
Jacob Steenhagen
2010-02-09 21:12:39 UTC
Permalink
It's generally considered bad security practice to allow a user to access
things stored at any arbitrary location of the server. The way you're using
it is actually quite rare.

Have you tried simply creating a symlink inside <dokuwiki_root>/data/media
to /home/chris/pictures (and setting it up so the apache user has access to
your /home dir)?
Post by Chris G
I am running DokuWiki for personal use on my desktop machine (xubuntu
9.10) and would like to display image files stored in the local file
system in DokuWiki but at the moment I can't see any way to do this.
Am I missing something?
The {{xxx:yyy:image.png}} syntax expects the image file to be in a
namespace, and it isn't. The alternative URL syntax only seems to
recognise http: URLs and the images aren't served by apache.
I've tried a file URL:-
{{file:///home/chris/pictures/2000s/2009/09 Sept 6-13 -
Sarthe/DSCF2019.JPG}}
but DukuWiki just turns this into one long filename with the / and
spaces turned into underscores.
I don't really want to copy the images into DikuWiki, a waste of space
and changes I make to the 'master' image won't get propogated.
--
Chris Green
--
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist
--
http://jacob.steenhagen.us
Chris G
2010-02-09 22:07:02 UTC
Permalink
Post by Jacob Steenhagen
It's generally considered bad security practice to allow a user to access
things stored at any arbitrary location of the server. The way you're
using it is actually quite rare.
Have you tried simply creating a symlink inside <dokuwiki_root>/data/media
to /home/chris/pictures (and setting it up so the apache user has access
to your /home dir)?
Yes, I was thinking that symlinks may be the way to go. One can even
seet apache2's 'followsymlinks' so that apache can see the symlinked
file without exposing *everything* to the outside world.

What I *really* want is a way to tell dokuwiki that I want it to
create a symlink rather than copying the file. As it is I'll have to
get dokuwiki to copy the file, then I delete it and put a symlink
there instead.
--
Chris Green
--
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist
Dmitry Katsubo
2010-02-10 14:16:28 UTC
Permalink
Post by Chris G
What I *really* want is a way to tell dokuwiki that I want it to
create a symlink rather than copying the file. As it is I'll have to
get dokuwiki to copy the file, then I delete it and put a symlink
there instead.
If you create a symlink for a namespace (= directory), you don't need to
play with replacing files with symlinks. You can also submount (mount
-bind) the namespace, maybe it will be better.

Tell us, what you want to achieve, maybe we have a nice solution for
that. What I see from your emails is that you want users to upload files
via wiki and then refer them from a page. That is doable. But there is
one problem here: dokuwiki will reject files, which are not following
certain format (all in lowercase, spaces replaced by underscore).

Does anybody know, how difficult is to switch off this limitation, and
allow wiki to store files as they are submitted (no convering to
lowercase and tricks with spaces)? I am afraid, that affects also the
names of the pages, but can it be done separately (one standard for page
names, and another for media file names)?

Thanks
--
With best regards,
Dmitry
--
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist
Chris G
2010-02-10 17:52:42 UTC
Permalink
Post by Dmitry Katsubo
Post by Chris G
What I *really* want is a way to tell dokuwiki that I want it to
create a symlink rather than copying the file. As it is I'll have to
get dokuwiki to copy the file, then I delete it and put a symlink
there instead.
If you create a symlink for a namespace (= directory), you don't need to
play with replacing files with symlinks. You can also submount (mount
-bind) the namespace, maybe it will be better.
Tell us, what you want to achieve, maybe we have a nice solution for
that. What I see from your emails is that you want users to upload files
via wiki and then refer them from a page. That is doable. But there is
one problem here: dokuwiki will reject files, which are not following
certain format (all in lowercase, spaces replaced by underscore).
There's only one user, me. I'm using Dokuwiki to document and record
a personal project. It's all running on one computer with apache2 set
up so that it's not visible outside the home LAN.

I have a large collection of pictures maintained using Digikam, I want
to use some of these pictures in the Dokuwiki project. I *don't*
really want to copy the pictures, they're already on the system that
apache2 is running on so there's no need. I also want to use the
'original' images so that changes and editing that I do in Digikam
will be seen in Dokuwiki.

So it seems to me that the obvious way to do it would be to have
symbolic links (Unix/Linux ones) from the Dokuwiki namespaces to the
Digikam images.
Post by Dmitry Katsubo
Does anybody know, how difficult is to switch off this limitation, and
allow wiki to store files as they are submitted (no convering to
lowercase and tricks with spaces)? I am afraid, that affects also the
names of the pages, but can it be done separately (one standard for page
names, and another for media file names)?
Symbolic links would allow change of name without problems.
--
Chris Green
--
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist
Michiel Kamermans
2010-02-13 08:55:07 UTC
Permalink
so it seems to me that the obvious way to do it would be to have
symbolic links (Unix/Linux ones) from the Dokuwiki namespaces to the
Digikam images.
You're already running a server yourself, so an alternative is to write
a simple php image serving script and put that wherever is convenient
for your local server, then making your on-page image links point to
"/somewhere/on/your/server/myimgservingscript.php?image=localimagelocation"
instead of just the filename for your image.

With the magic of GD, all the script needs in order to serve up
requested images is four lines of code:

<?php
header('Content-Type: image/jpeg'); // change content type
accordingly, you could even switch based on input param
$img = imagecreatefromjpeg($_GET['image']);
imagejpeg($img); // or gif, png or wbmp, which covers all the
normal web-understood image formats
imagedestroy($img);
?>

and since you're running local only, there's no need to make sure that
$_GET['image'] is unsafe. You can even make it aware of where pictures
are generally stored on your local system and have it check for the dir
location before loading it, so that specifying filename alone will do
the trick.

Personally, I go with image serving every time I'm in situations like
this, because relying on symlinks means you need a new link every time
you have a new image you also need to make a new symlink, rather than
not needing anything new at all.

- Mike "Pomax" Kamermans
--
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist
Chris G
2010-02-13 09:38:33 UTC
Permalink
Post by Michiel Kamermans
so it seems to me that the obvious way to do it would be to have
symbolic links (Unix/Linux ones) from the Dokuwiki namespaces to
the Digikam images.
You're already running a server yourself, so an alternative is to
write a simple php image serving script and put that wherever is
convenient for your local server, then making your on-page image
links point to "/somewhere/on/your/server/myimgservingscript.php?image=localimagelocation"
instead of just the filename for your image.
With the magic of GD, all the script needs in order to serve up
<?php
header('Content-Type: image/jpeg'); // change content type
accordingly, you could even switch based on input param
$img = imagecreatefromjpeg($_GET['image']);
imagejpeg($img); // or gif, png or wbmp, which covers all the
normal web-understood image formats
imagedestroy($img);
?>
and since you're running local only, there's no need to make sure
that $_GET['image'] is unsafe. You can even make it aware of where
pictures are generally stored on your local system and have it check
for the dir location before loading it, so that specifying filename
alone will do the trick.
Personally, I go with image serving every time I'm in situations
like this, because relying on symlinks means you need a new link
every time you have a new image you also need to make a new symlink,
rather than not needing anything new at all.
This sounds like an excellent approach, thank you. As you say
symbolic links are not ideal and the above approach could, if
necessary, allow for moving the image storage.
--
Chris Green
--
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist
Loading...