Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save camAtGitHub/030e1d215c3ba1ac00836a060803f568 to your computer and use it in GitHub Desktop.

Select an option

Save camAtGitHub/030e1d215c3ba1ac00836a060803f568 to your computer and use it in GitHub Desktop.

Basic How-to

to can have multiple lines, every one of them will be converted to a result URL. If # is the first character in a line then it marks the URL as hi-res.

If # is not the first then it may be followed by space separated strings closed by a # sign again. This will generate URLs for every variant. E.g. some.url/path/full-image.#jpg png gif#, which will generate three URLs, testing them in order.

Also, at the end of the line you can add #{media_extension} eg: #jpg, so the the extension will recognize it as video or audio, instead of image (default). E.g., https://some.url/path/without/extension?id=13#mp4

Javascript RegExp is used (obviously). In the code it's simply RegExp('yourRegexInput'). The conversion happens with a simple URL.replace(yourRegex, rule.to).

res has different formats. If you simply write a regexp there, then the first group from the match will be the full image URL. If you have multiple groups, then starting with the second they will be concatenated to be used as caption. If you write a second regexp in a new line, then it's first group from the match will be the caption.

If res starts with :\n (so colon plus new line) then you can write JavaScript code there, and do whatever you want. A $ variable will be available in that piece of code, which holds the resolved content for example ($._). From res you can return null, this will make the spinner yellow. Other falsy values will hide the spinner. You can return a string, that will be the URL. An array with two members [URL, caption]. An array with multiple of the previous is an album.

The :\n works in to as well (but the $ value there will have only the matched groups).

From every URL, before it's sent to matching, the https?://(www\.)? part is removed (and added to the result URL later, if you don't start to with a protocol). So, you're basically matching some.url/thumbnail.jpg instead of https://some.url/thumbnail.jpg. The reason for this is to allow the use of ^ (which you already noticed).

Source

Advanced configuration

The fields can contain a JavaScript function or a Regex.

  • link recives the address of any link you hover over.
  • url uses captured parentheses values from the link field to make an url.
  • res recives whatever page, in text, that was pointed to by url or link.

If one of them is empty, that step is skipped, e.g. no url and res just loads from link's output. A simple example is the xkcd filter: link:

^(xkcd\.(?:org|com)/\d{1,5})/?$

Finds links to xkcd comics. If you're unfamiliar with regex, anything between the parentheses is saved and can be used in Imagus as "$n" to refer to the nth capture. Note that if there's a "?:" after the first parentheses it wont get captured.

url:

$1/info.0.json

This simply appends "/info.0.json" to the address from link.

res:

:
if ($._[0] != '{') $ = null;
else $ = JSON.parse($._), $ = [$.img, [$.year, ('0'+$.month).slice(-2),
('0'+$.day).slice(-2)].join('-') + ' | ' + $.safe_title + ' - ' + $.alt + ' ' +
$.link];
return $;

This javascript function parses the JSON file and returns an array where the first element is the link and the second is the caption text displayed under the hoverzoomed image. If you return just a link then the caption will be the alt text of the link.

  • img is used as link is, but for image sources
  • to is used as res or url is

A simple use case is when you want to redirect from thumbnails to hires. Like the filter for wikimapia.org.
img:

^(photos\.wikimapia\.org/p/[^_]+_(?!big))[^.]+

This finds any wikimapia image that doesn't have big in the name.

to:

$1big

Adds big to the url.

  • note is just for notes.

Some filters have links to API docs here.

Now, there's no documentation for this feature yet so I probably missed a lot, but hopfully it'll be enough.

Source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment