diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini
index 65f77a9d3..6954370cf 100644
--- a/calibre-plugin/plugin-defaults.ini
+++ b/calibre-plugin/plugin-defaults.ini
@@ -1265,11 +1265,11 @@ remove_transparency: true
## kept.)
#dedup_img_files:false
-## If set true, FFF will use the img tag's own src URL as the HTTP
-## Referer instead of the page URL. This is useful for some image
-## hosting sites that watermark or return HTML instead of image data
-## without it.
-#force_img_self_referer:false
+## If set, and the img tag's URL matches the regular expression, FFF
+## will use the img tag's own src URL as the HTTP Referer instead of
+## the page URL. This is useful for some image hosting sites that
+## watermark or return HTML instead of image data without it.
+#force_img_self_referer_regexp:gelbooru.com|photobucket.com
## if the tag doesn't have a div or a p around it, nook gets
## confused and displays it on every page after that under the text
diff --git a/fanficfare/configurable.py b/fanficfare/configurable.py
index d27c9b800..c8b7d9907 100644
--- a/fanficfare/configurable.py
+++ b/fanficfare/configurable.py
@@ -375,7 +375,7 @@ def get_valid_keywords():
'dateUpdated_format',
'default_cover_image',
'force_cover_image',
- 'force_img_referer',
+ 'force_img_self_referer_regexp',
'description_limit',
'do_update_hook',
'use_archived_author',
diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini
index 2a858906f..e6e17d26d 100644
--- a/fanficfare/defaults.ini
+++ b/fanficfare/defaults.ini
@@ -1264,11 +1264,11 @@ remove_transparency: true
## kept.)
#dedup_img_files:false
-## If set true, FFF will use the img tag's own src URL as the HTTP
-## Referer instead of the page URL. This is useful for some image
-## hosting sites that watermark or return HTML instead of image data
-## without it.
-#force_img_self_referer:false
+## If set, and the img tag's URL matches the regular expression, FFF
+## will use the img tag's own src URL as the HTTP Referer instead of
+## the page URL. This is useful for some image hosting sites that
+## watermark or return HTML instead of image data without it.
+#force_img_self_referer_regexp:gelbooru.com|photobucket.com
## if the tag doesn't have a div or a p around it, nook gets
## confused and displays it on every page after that under the text
diff --git a/fanficfare/story.py b/fanficfare/story.py
index 969746bc7..d21db5c8e 100644
--- a/fanficfare/story.py
+++ b/fanficfare/story.py
@@ -1548,7 +1548,9 @@ def addImgUrl(self,parenturl,url,fetch,cover=False,coverexclusion=None):
# and authors who link images that watermark or
# don't work anymore.
refererurl = parenturl
- if self.getConfig("force_img_self_referer"):
+ if( self.getConfig("force_img_self_referer_regexp") and
+ re.search(self.getConfig("force_img_self_referer_regexp"),
+ url) ):
refererurl = url
logger.debug("Use Referer:%s"%refererurl)
imgdata = fetch(imgurl,referer=refererurl)