wiki: image include from gallery

Let the developers know what you think of the software and what can be done to either improve the CFDG language or the Context Free program.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
User avatar
kipling
Posts: 91
Joined: Wed Jun 18, 2008 2:36 am

wiki: image include from gallery

Post by kipling »

Is there any reason not to allow images in the gallery to be available on the wiki? I guess this is a request for a change in the mediawiki configuration, in particular the built-in settings that allow all or some sources of external image inclusions, such as So for instance if the cf wiki had

Code: Select all

$wgAllowExternalImagesFrom = array ( 'http://www.contextfreeart.org/gallery/' , 'http://glyphic.s3.amazonaws.com/cfa/gallery/uploads/' )
OR
$wgAllowExternalImagesFrom = 'http://www.contextfreeart.org/gallery/'
Then we could include gallery images in the wiki. This would be handy - in writing the tutorials and such in the wiki, it would be nice to at least have a thumbnail link to the gallery without having to upload a thumbnail into the wiki. The actual link & img could be coded via a mediawiki template.

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Post by MtnViewJohn »

I have
$wgAllowExternalImages = true;
in the settings file. It doesn't work?

User avatar
kipling
Posts: 91
Joined: Wed Jun 18, 2008 2:36 am

Post by kipling »

Oh OK it does work if you try - I didn't try hard enough.

See http://www.contextfreeart.org/mediawiki ... er:Kipling for what was confusing me. Are the trailing ?n numbers the version numbers (such as when the image is uploaded). If so, does omitting them (as seems to be necessary) give the first or last version?

Before I put together a wiki template to automatically import the thumbnail of a gallery design, it would be nice to know if the thumbnails have URLs other than those that appear in the gallery pages. Looking at these, it seems that you have them at
uploads/x/y/hash/sm_thumb_nnnn.png
where "hash" is unique to the author (hash of name or user id, I guess), and x and y are the first two bytes of this hash.

The problem is that the wiki template will have to have the x/y/hash as a parameter, or the whole URL. It would be much cleaner if there were alternative URLs like http://contextfree.org/gallery/thumb/nnnn.png (either as static files or via a PHP script that does this on the fly). Then I could write a wiki template that say took {{gallerythumb|id=1828|title=ammonite|author=bloop}} to create a nice little captioned thumbnail linked to the gallery. Otherwise I will also have to have, for example
url=http://www.contextfreeart.org/gallery/u ... b_1828.jpg
or
dir=4a/ca/4aca29c7c0a76c1cbaad40b2693e6bef
both of which would require the wiki author to looking up the thumbnail image URL, trim off the "?1", etc.

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Post by MtnViewJohn »

The ?0 at the end is to prevent browsers from caching older versions of gallery images. If you upload a new image for a particular design then it will end in ?1. The web server ignores the ?0 (or ?1 or ?64738) and always serves the latest version of the image. Mediawiki probably sees that the url does not end in .jpg or .png so it thinks it isn't an image.

I think that you will need to give the whole URL as the template parameter. While the gallery currently uses uploads/x/y/hash/sm_thumb_nnnn.png as the file location it used to use another scheme. We never converted the older file locations to the new scheme. A PHP script for serving up images would be pretty easy. I'll get right on it. How about:
The type parameter can be cfdg, thumb, smallthumb, or full.

User avatar
kipling
Posts: 91
Joined: Wed Jun 18, 2008 2:36 am

Post by kipling »

Yes, that was the conclusion I reached while playing in my sandbox. The trick would be to have the URL end in jpg or png so that the wiki would recognise it. This might work:

Code: Select all

http://www.contextfreeart.org/gallery/data.php?filename=sm_thumb_nnn.png
It really depends how smart the wiki parser is. If not, you will have to change your apache config (if you are using apache) so that all URLs like

Code: Select all

http://www.contextfreeart.org/gallery/thumb/sm_thumb_nnn.png
go to a single php script that parses the incoming URL to extract the file name. Not hard to do on apache (did it myself some years ago for some purpose I've forgotten) and there are probably examples in the php documentation.

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Post by MtnViewJohn »

Go look at what I did to your user page. It appears that the wiki isn't smart about parsing URLs. It just looks for .jpg or .png at the end of the url. The extension on the URL doesn't even need to match the image file type. I changed the URL to end with ?0.png even though it is a JPEG file and it still worked.

User avatar
kipling
Posts: 91
Joined: Wed Jun 18, 2008 2:36 am

Post by kipling »

OK this could give a nice workaround, by engineering a gratuituous .png on the end of the URL, say hidden in an unused GET parameter. However, I tried the URL you proposed and various modifications in the wiki:

Code: Select all

http://www.contextfreeart.org/gallery/data.php?id=nnnn&type=thumb
http://www.contextfreeart.org/gallery/data.php?id=nnnn&type=thumb&ext=.png
and it doesn't parse to an <img> tag. See my user page.
The fact that it doesn't care about image type is probably due the wiki parser just translating the URL as given into an <img> tag, and the browser sorting it out once the image bits arrive.

Just on my suggestion of messing with your apache config so that http://contextfreeart.org/gallery/thumb/nnnn.png is turned into a URL like that above, the most lightweight way is probably via apache's mod_rewrite for regexp URL substitution on the fly. See http://www.workingwith.me.uk/articles/s ... od_rewrite for something that looks very close to what is required.

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Post by MtnViewJohn »

OK, we will go with mod_rewrite.

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Post by MtnViewJohn »

data.php has been uploaded to the site. I didn't have to use mod_rewrite. PHP just took everything after 'data.php' and stuck it in a $_SERVER variable.

Check-out your wiki user page to see it working. Go to http://www.contextfreeart.org/gallery/data.php for info on how to use it.

User avatar
kipling
Posts: 91
Joined: Wed Jun 18, 2008 2:36 am

Post by kipling »

OK - excellent. I will have a go at a wiki template when I am next playing with that.
BTW - you invited us to respond to a thread in "announcements" that we can't post to, so I'll do it here. Upload from the Mac CF program is now broken, maybe due to the UTF-8 issue. The error message was that I was missing a title.

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Post by MtnViewJohn »

The problem was that I changed the name of the title field in the form, but Context Free uses the original field name. So I changed the field name back. I also changed the Announcements forum so that anyone can reply to posts. Would you do a test reply the thread in the Announcements forum?

User avatar
kipling
Posts: 91
Joined: Wed Jun 18, 2008 2:36 am

Post by kipling »

OK I have now written two templates, one for the small thumbnail (100x100) and one for the larger thumbnail (300x300). The larger one has an optional "caption" argument. All illustrated on http://www.contextfreeart.org/mediawiki ... er:Kipling.
Thanks for enabling this. This will get used in the tutorials, obviously

Post Reply