no_images plugin

Post plugins and custom CSS snippets here
Bear Rating Master
Bear Rating Master
Posts: 144
Joined: 23 Aug 2013, 19:52

no_images plugin

Postby pcause » 04 Sep 2013, 20:31

**EDITED* See comment at end

When you check the box not to embed images in your display, ttrss turns the images into links. For me this left a lot of crap at the end of the content display of feeds. I asked Fox about this and he "suggested" that I solve this with a plugin. New to ttrss, but here goes:

Create a directory in your plugins directory called no_images.

Copy this code and paste it in a file called init.php in the no_images directory:

Code: Select all

class No_Images extends Plugin {
   private $host;

   function about() {
      return array(1.0,
         "Remove all images without leaving a trace",

   function init($host) {
      $this->host = $host;

      $host->add_hook($host::HOOK_SANITIZE, $this);

   function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes) {

      $xpath = new DOMXPath($doc);
      $entries = $xpath->query('//img[@src]');
      foreach ($entries as $entry) {
         $p = $entry->parentNode;
         $n = $doc->createElement('img');
      return $doc;

   function api_version() {
      return 2;


Go to preferences. Uncheck the setting for embedded images and enable the no_images plugin.

My first attempt at this. Working on my system, but please let me know if you have a problem.

EDIT: Changed the code a bit. it turns out that if you uncheck the embed images preference and there are enclosures and there are no img tags in the content (which there won't be after the original code ran) than if there are enclosures with images they get displayed. Converting the image tags to img tags without a source seems to be a hack to fix this. Looking for something more elegant.

Bear Rating Trainee
Bear Rating Trainee
Posts: 20
Joined: 21 Mar 2013, 01:27

Re: no_images plugin

Postby mkl » 06 Dec 2013, 22:46

It works well


Return to “Themes and plugins”

Who is online

Users browsing this forum: No registered users and 2 guests