N
N
Neocaridina2017-02-06 05:02:19
JavaScript
Neocaridina, 2017-02-06 05:02:19

If there is no picture, how to take it from another host?

If there is no image on host1, display it on the page from host2.
Including subfolders etc.
You need to play around with a copy of the site in the sandbox, and the pictures there between the files will only interfere.
PS: Well, or in general, all the pictures on the mask.
PPP: Well, or another method, mb JS? (just not inline to every link)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2017-02-06
@Neocaridina

;(function(){
  [].slice.call(document.querySelectorAll('img'))
    .forEach(img=>img.addEventListener('error', evt=>{
    img.src = img.src.replace(
      'https://fiddle.jshell.net/badpath/',
      'https://i.imgur.com/'
    )
  }))
})()

UPD : It turns out that the img.onerror event does not pop up, so you have to hang a handler on every img tag.
Working example: https://jsfiddle.net/Stalk/j3q47rco/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question