summaryrefslogtreecommitdiff
path: root/src/dicache.c
diff options
context:
space:
mode:
authorRodrigo Arias Mallo <rodarima@gmail.com>2024-12-08 16:34:26 +0100
committerRodrigo Arias Mallo <rodarima@gmail.com>2024-12-08 21:26:09 +0100
commit4ca80d0be53d50c0db7de7f81a3df8dbb1565f98 (patch)
treee00a6f4cb9a8dd563e22e82d092ffa36823e2446 /src/dicache.c
parentd4f56d0d8d07dd45600eca76551c011e290e4520 (diff)
Allow image formats to be disabled from dillorc
Makes disabling certain formats posible without the need to rebuild Dillo from source. See: https://github.com/dillo-browser/dillo/pull/312
Diffstat (limited to 'src/dicache.c')
-rw-r--r--src/dicache.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/dicache.c b/src/dicache.c
index e86f5655..e53fb011 100644
--- a/src/dicache.c
+++ b/src/dicache.c
@@ -25,13 +25,23 @@
#include "dsvg.h"
enum {
- DIC_Gif,
+ DIC_Gif = 0,
DIC_Png,
DIC_Webp,
DIC_Jpeg,
- DIC_Svg
+ DIC_Svg,
+ DIC_MAX
};
+static const char *format_name[DIC_MAX] = {
+ [DIC_Gif] = "gif",
+ [DIC_Png] = "png",
+ [DIC_Webp] = "webp",
+ [DIC_Jpeg] = "jpeg",
+ [DIC_Svg] = "svg"
+};
+
+static int disabled_formats[DIC_MAX] = { 0 };
/**
* List of DICacheEntry. May hold several versions of the same image,
@@ -67,6 +77,15 @@ void a_Dicache_init(void)
{
CachedIMGs = dList_new(256);
dicache_size_total = 0;
+
+ if (prefs.ignore_image_formats) {
+ for (int i = 0; i < DIC_MAX; i++) {
+ if (dStriAsciiStr(prefs.ignore_image_formats, format_name[i])) {
+ disabled_formats[i] = 1;
+ _MSG("Image format %s disabled\n", format_name[i]);
+ }
+ }
+ }
}
/**
@@ -372,6 +391,11 @@ static void *Dicache_image(int ImgType, const char *MimeType, void *Ptr,
dReturn_val_if_fail(MimeType && Ptr, NULL);
+ if (ImgType >= 0 && ImgType < DIC_MAX && disabled_formats[ImgType]) {
+ _MSG("Ignoring image format %s\n", format_name[ImgType]);
+ return NULL;
+ }
+
if (!web->Image) {
web->Image =
a_Image_new_with_dw(web->bw->render_layout, NULL, web->bgColor, 0);