Allow images from GitHub domain on the wiki

Could the gramps-projects allow GitHub images to make drafting addon documentation easier?

Uploading screen captures to the wiki is awkward.

And while in beta, the dialogs for addons are in continous revision but the wiki image system is too wasteful … it maintains a history of “throwaway” images.

If we could use GitHub images (posted to repositories for use in README.md docs) during the early documentation, then it becomes easier to support quality documentation during the “Addon” beta cycle.

This Discourse domain might be another trusted image source.

(When the addon goes into broad release, the image should be committed to the wiki.)

from Google AI Overview
Images from other domains can be used in MediaWiki if the system administrator enables the option and a user uploads the file. By default, images from outside the wiki are not displayed to prevent malicious users from collecting visitor information.

To enable external images, you can:

  1. Add $wgAllowExternalImages = true; to LocalSettings.php
  • To restrict the list of domains, use $wgAllowExternalImagesFrom

Once enabled, users can add images from external domains by pasting the image’s full URL into the wiki text. For example, https://domain.com/images/image_file.png will display the image.

If you want to use images from a trusted source, like your own domain, you can set $wgAllowExternalImages to false and use $wgAllowExternalImagesFrom

1 Like

Sample MediWiki markup: for the native wiki domain and another with a GitHub target.

[[https://gramps-project.org/wiki/images/7/75/ChartsCategory-PedigreeView-PersonContextMenu-showing-Children-example-52_he.png|thumb|right|450px|Addon GUI (e.g. detached gramplet screen capture)]]

[[https://github.com/kajmikkelsen/HistContext/blob/master/gramplet.png|thumb|right|450px|Addon GUI (e.g. detached gramplet screen capture)]]

Or with standard HTML instead of markup:

<img src="https://github.com/kajmikkelsen/HistContext/blob/master/gramplet.png" width="450" align="right" alt="Addon GUI (e.g. detached gramplet screen capture)" />

I believe the wiki already allows this because the on the portal translators page it shows an external image from the weblate website ( see the following template Template:Translators/Weblate looking at the templates view source page the links to the images are plain urls eg

https://hosted.weblate.org/widgets/gramps-project/-/287x66-grey.png < br />
https://hosted.weblate.org/widgets/gramps-project/-/gramps/multi-auto.svg.png

@sam888 so maybe just the domain needs to be whitelisted?

2 Likes

Checked the wiki and see that I already added urls for github and gramps discourse back in May 2021 , but as @Gioto points out the only format accepted using this method are bare (plain) urls (but you can embed the url in a table).

Current settings from Gramps mediawiki ( LocalSettings.php )

#### Allows external images from select urls added 2021/06/05 (sm)###
$wgAllowExternalImagesFrom = [
    'https://hosted.weblate.org/',
    'https://gramps.discourse.group/',
	'https://github.com/'	
];

This does not guarantee that the listed websites allow hotlinking / embedding an image from them.

my reference:

2 Likes

I tried previewing bare URL tests for a .png from Kaj’s HistContext repository. And the wiki just rendered the URL…maybe ‘Preview’ isnt enough?

https://github.com/kajmikkelsen/HistContext/blob/master/gramplet.png

(Discourse tries but says the bare URL is a binary file. So had to wrap the URL with a link markup.)

I’m guessing on mediawiki with external images a preview will not work until added based on my test as the weblate url does not show a preview also!

@gramps-project For github you may also need to add the supplemental url

https://raw.githubusercontent.com

so that linking to a raw image from github works?

https://raw.githubusercontent.com/kajmikkelsen/HistContext/refs/heads/master/gramplet.png

Have not tested discourse image linking yet. seems to use

https://canada1.discourse-cdn.com

based on looking at about twenty images on gramps discourse, so try that one please?

3 Likes

Ok, added the extra urls

#### Allows external images from select urls added 2021/06/05 (sm)###
#### updated 2023/11/09 (sm) https://gramps.discourse.group/t/allow-images-from-github-domain-on-the-wiki/6402 ###
$wgAllowExternalImagesFrom = [
    'https://hosted.weblate.org/',
    'https://gramps.discourse.group/',
    'https://raw.githubusercontent.com/',
    'https://canada1.discourse-cdn.com/',
	'https://github.com/'	
];

and can see on your sandbox page that the images are showing.

Thanks for testing and working that out :slight_smile:

@emyoulation Please test.

2 Likes

Thanks. That makes this the test data to be used for writing the WikiContributor docs.

From Discourse for @kmikkels HistContext gramplet on wiki:

https://gramps.discourse.group/t/my-first-gramplet-for-gramps-5-2/6348/63

when editing the posting, this is how Discourse markup IDs the image:

![image|432x500, 75%](upload://8p4psndyzjSvbdlG9Ih7qEe6wgY.png)

right-click to open image in new window:

https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/3/3ae6e85a9c69d04cd4dd50c8fbfc99bc4ed2124c.png

From GitHub

https://github.com/kajmikkelsen/HistContext/blob/master/gramplet.png wrapped with server content

https://github.com/kajmikkelsen/HistContext/blob/master/gramplet.png?raw=true just shows as URL

https://raw.githubusercontent.com/kajmikkelsen/HistContext/blob/master/gramplet.png bad link

https://raw.githubusercontent.com/kajmikkelsen/HistContext/refs/heads/master/gramplet.png

1 Like

@Gioto thanks very much! The tests works. Time to build the transclusion template.
How did you suss out the /refs/head/ portion of the GitHub URL?

@gramps-project Thanks for the new trusts!

1 Like

Only experimentation and a bit of luck!

Darn. We are going to have a structured way to extract that part of the path if it is going to be part of the new addon wiki documentation template.

There is a reproducible method for extracting the Discourse image path. We will need something for similar for GitHub images. (Since they could be in branches, we cannot assume they will always be in a refs/head/ path.)

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.