-
Notifications
You must be signed in to change notification settings - Fork 103
Media preview
Weechat-Android supports fetching and displaying images and stills of GIFs directly or through open graph tags. You can set it up to try to display an image for every link it encounters, or to only fetch data from the websites you trust. Only HTTP URLs are considered.
The images are only fetched when you are using the app, except the images in notifications—these are fetched right away. The images and the thumbnails generated from these are cached on disk (LRU cache) and not fetched again, unless the app runs of allotted cache space. Errors are temporarily cached as well.
The app will not make any web requests at all if the feature is disabled.
If enabled, it will make requests directly to the websites. Your ISP will see the websites you are connecting to. The websites you are accessing will know your IP and the User Agent of your device. There could be two issues with this:
-
If you are using insecure requests, everyone on your network could see transferred data. Unless you absolutely need it, don't set
Insecure requests
toAllow
, the other options are safe. -
Someone could send you a link to an image and learn your IP and other data when the device fetches it. (They will learn the same if you tap on it.) You can prevent this by not having a strategy for websites you don't know. To do that, remove the strategy
try the rest
, and perhaps add websites you visit to strategycommon/https
.
Note that the application still follows redirects, and these can lead you to different websites. While the strategies are not used for redirects, the app will check if there's a strategy of type none
for a redirect and stop it from executing if there's one. So if you are worried that a website you trust could redirect you to one you don't, you can add this strategy:
- name: skip the rest, including redirects
type: none
hosts: ['*']
-
Select networks on which the feature is active. “Unmetered networks” are the ones designate as such by your device; you can usually mark networks as metered or unmetered in network settings.
-
Select places in the app where the feature is active. Older devices can't display images in notifications, instead, they display the text “under” the image, which appears as duplicate lines. Notifications could be forwarded to devices that can display the images, so the feature is not disabled automatically.
-
Defines what to do with insecure, non-HTTPS URLs. If you choose
Rewrite as HTTPS
, ans
is simply added to the scheme. Choosing secure requests will also prevent redirects from HTTPS to HTTP. -
This setting is using
YAML
format. You can reset it to the default value from the three dots menu. The regexes used in this setting are matched usingfind()
, that is, if you want them to match the whole string, use^
and$
.-
This filter prevents parts of messages from being linkified. For instance, matrix bridge users will often say something along:
Alice: <Bob "this is a quoted truncated messa"> reply
This will truncate the URL, which can lead to an unwanted image being shown. To avoid this, you can define here a regex that matches the quote format:
^<[^ ]{1,16} ".{1,33}">\s
. -
These are used to prevent images from being displayed for certain users and lines
-
nicks
: optional. list of nicks to filter out. if omitted, filters all nicknames -
regex
: optional. e.g.^Title:
will skip all lines starting withTitle:
.
-
-
A strategy defines the way the image are fetched (or not) for a particular URL. A strategy is considered for an URL if the URL matches on of the host patterns it defines. If the strategy defines a regex, and it matches the URL, or if it doesn't define a regex, this strategy is then used, and no other strategy is considered. If the regex doesn't match, other strategies are attempted. If no strategies exist for the URL, the URL is ignored.
Every strategy has three mandatory options:
-
name
: arbitrary text used only as description -
hosts
: a list of hosts that this strategy is for. In the order of priority, these can be:- exact match.
example.com
will only matchexample com
and not its subdomains; - higher-order partial match.
*.example.com
will matchwww.example.com
andfoo.bar.example.com
; - lower-order partial matches:
*.com
,*
. the latter will match every website;
If there are two strategies matching the same host, the one defined first has priority.
- exact match.
-
type
: one ofnone
,image
orany
Currently there are three kinds of strategies, more could be added in the future.
-
Strategy of type
none
prevents the matching hosts from being accessed. this includes redirects. this strategy has no additional options.For example, this strategy prevents the app from accessing the websites for which other strategies were not defined, even if a website with a defined strategy redirects to one.
- name: skip the rest, including redirects type: none hosts: ['*']
-
Strategy of type
image
directly fetches a single image. It has the following options:-
regex
: optional. The URL must match the pattern. -
small
: optional. Instead of the original URL, fetch the one specified by this setting, with$1
,$2
replaced with groups 1, 2 of the above regex. Used for small thumbnails. -
big
: optional. same assmall
, used for notifications. if not specified, does not fall back tosmall
.
For example, imgur provides big and small thumbnails for its media (videos, too!) Upon encountering the host
i.imgur.com
, this directly fetches the thumbnail of appropriate size.- name: i.imgur type: image hosts: [i.imgur.com] regex: (?i)^https?://i\\.imgur\\.com/([A-Za-z0-9]+) small: https://i.imgur.com/$1m.jpg big: https://i.imgur.com/$1h.jpg
-
-
Strategy of type
any
fetches the image either directly or through the Open Graph HTML tags. A page is partially read, the tags such as<meta property="og:image" ... />
are examined and the final request is made for the image. This strategy has the following options:-
regex
: optional. The URL must match the pattern, same as theimage
strategy. -
sub
: optional. Same asbig
andsmall
of the image strategy. -
body size
: optional, default: 16384 bytes (16KB). Amount of data to read from the server, when looking for open graph tags.
For example,
mobile.twitter.com
doesn't provide open graph tags, but the URL follows the same pattern astwitter.com
, which does. This strategy removesmobile.
from the host and makes the URL secure if it wasn't. Note: even if a strategy produces a HTTP-only URL,- name: mobile.twitter type: any hosts: [mobile.twitter.com] regex: (?i)^https?://mobile\\.twitter\\.com/(.*) sub: https://twitter.com/$1
-
-
-
-
If the data has length and it exceeds the limit, don't fetch it. If it has no length, abort the connection if it goes over the limit. Affects all requests.
-
Takes effect on restart. To clear cache, go to
App info
→Storage & cache
. If you are having any problems with cache, you can also try stopping the application first. -
When the app encounters a new URL, it doesn't know if it will lead to an image or not. So it displays text without allocating space for the image, and if the image is fetched, the space is made and the image is animate into it. It would be nice to forgo the animation if we know that the image can be fetched—especially if it is in the cache. But the cache is on disk, and querying it could be prohibitively slow. So instead of that, we simply remember that some URLs have been successfully displayed, and skip the animation. This settings specifies for how long successful fetches of images are considered successful. Lower the hours of this setting if you see any weird animation.
-
Thumbnails have fixed with and variable height. Use these to specify the former and limit the latter in
dp
(device-independent pixels).