all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#49344: shr: Add support for "data-src" attribute in <img> nodes
@ 2021-07-03  0:56 杨英超
  2021-07-04  5:46 ` Phil Sainty
  0 siblings, 1 reply; 4+ messages in thread
From: 杨英超 @ 2021-07-03  0:56 UTC (permalink / raw)
  To: 49344


[-- Attachment #1.1: Type: text/plain, Size: 466 bytes --]

Dear maintainers:

I found eww fails to show card-images which is described in the following
web page:

https://www.geeksforgeeks.org/why-card-images-use-data-src-not-src-for-image-in-bootstrap-4/

For example, if you open following page with eww & firefox, you will notice
the differences:   http://www.interdb.jp/pg/pgsql05.html

I modified shr.el a little bit to support "data-src" attribute, so eww can
display card-images properly.

 Hope it helps.

Regards
yc

[-- Attachment #1.2: Type: text/html, Size: 833 bytes --]

[-- Attachment #2: 0001-Add-support-for-data-src-attribute-in-img-tag.patch --]
[-- Type: text/x-patch, Size: 1250 bytes --]

From bb7537f18af348e27169fdb4675279a6ac936f91 Mon Sep 17 00:00:00 2001
From: yangyingchao <yangyingchao@icloud.com>
Date: Fri, 2 Jul 2021 11:46:12 +0800
Subject: [PATCH] Add support for "data-src" attribute in <img> tag.

* lisp/net/shr.el (shr--preferred-image) (shr-tag-img): support
  "data-src"  attribute
---
 lisp/net/shr.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 873f0457e3..cc2007b2a4 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1661,7 +1661,8 @@ shr-tag-img
   (when (or url
 	    (and dom
 		 (or (> (length (dom-attr dom 'src)) 0)
-                     (> (length (dom-attr dom 'srcset)) 0))))
+                     (> (length (dom-attr dom 'srcset)) 0)
+                     (> (length (dom-attr dom 'data-src)) 0))))
     (when (> (current-column) 0)
       (insert "\n"))
     (let ((alt (dom-attr dom 'alt))
@@ -1793,7 +1794,7 @@ shr--preferred-image
                   (> (cadr (car srcset)) frame-width))
         (setq candidate (caar srcset))
         (pop srcset)))
-    (or candidate (dom-attr dom 'src))))
+    (or candidate (dom-attr dom 'src) (dom-attr dom 'data-src))))
 
 (defun shr-string-number (string)
   (if (null string)
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-05  0:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-03  0:56 bug#49344: shr: Add support for "data-src" attribute in <img> nodes 杨英超
2021-07-04  5:46 ` Phil Sainty
2021-07-04 13:55   ` Lars Ingebrigtsen
2021-07-05  0:16     ` 杨英超

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.