unofficial mirror of bug-gnu-emacs@gnu.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

* bug#49344: shr: Add support for "data-src" attribute in <img> nodes
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Phil Sainty @ 2021-07-04  5:46 UTC (permalink / raw)
  To: 杨英超; +Cc: 49344

On 2021-07-03 12:56, 杨英超 wrote:
> https://www.geeksforgeeks.org/why-card-images-use-data-src-not-src-for-image-in-bootstrap-4/

The meaning of any 'data-*' attribute is 100% application-defined.
I don't think that any web browsers should be assuming that a
'data-src' attribute is actually a 'src' attribute (that's not
any kind of standard AFAIK), nor implement workarounds for specific
web sites that are not generating sane HTML.

The initial markup should have a proper 'src' attribute.  If the
site wants the initial state to be different in the presence of
Javascript, then it should be using Javascript to modify the
initial state accordingly, following a progressive-enhancement
approach.

As eww doesn't support Javascript, this particular case is only
one of many things which won't work when the site developers
make bad assumptions about Javascript.  I would expect your
example to fail in any web browser where JS was disabled or
not supported.

E.g. for me, using Firefox, the site looks very similar in
Firefox and eww because I use the uMatrix extension to only
permit Javascript to run on sites where I have explicitly
allowed it.  (Actually, the site looks *better* in eww, because
their code blocks in Firefox are barely readable on account
of the appallingly poor contrast between background and text.)

This is simply bad web design, and I don't think that's eww's
problem to solve.


-Phil






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

* 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     ` 杨英超
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2021-07-04 13:55 UTC (permalink / raw)
  To: Phil Sainty; +Cc: 杨英超, 49344

Phil Sainty <psainty@orcon.net.nz> writes:

> This is simply bad web design, and I don't think that's eww's
> problem to solve.

Indeed, so I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#49344: shr: Add support for "data-src" attribute in <img> nodes
  2021-07-04 13:55   ` Lars Ingebrigtsen
@ 2021-07-05  0:16     ` 杨英超
  0 siblings, 0 replies; 4+ messages in thread
From: 杨英超 @ 2021-07-05  0:16 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Phil Sainty, 49344

[-- Attachment #1: Type: text/plain, Size: 462 bytes --]

At your wish, although I don't agree. I have my own fork I can play with.

Lars Ingebrigtsen <larsi@gnus.org> 于2021年7月4日周日 下午9:55写道:

> Phil Sainty <psainty@orcon.net.nz> writes:
>
> > This is simply bad web design, and I don't think that's eww's
> > problem to solve.
>
> Indeed, so I'm closing this bug report.
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no
>

[-- Attachment #2: Type: text/html, Size: 921 bytes --]

^ permalink raw reply	[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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).