diff options
| author | horus | 2020-09-19 02:13:24 +0200 |
|---|---|---|
| committer | horus | 2020-09-19 02:13:24 +0200 |
| commit | b57bab1cf2e3e7d9b965bade697f209d8957080a (patch) | |
| tree | 58aa6bf9726945617178aaca6fffe929f6ec3704 /resources | |
| parent | 8e6c5c4b8f59e9874aa99bb5db5de8f521de0ab3 (diff) | |
| download | senpai-b57bab1cf2e3e7d9b965bade697f209d8957080a.tar.gz | |
dynamically update img src when camo proxy fails
Diffstat (limited to 'resources')
| -rw-r--r-- | resources/js/app.js | 7 | ||||
| -rw-r--r-- | resources/views/anime.blade.php | 2 | ||||
| -rw-r--r-- | resources/views/list_anime.blade.php | 2 |
3 files changed, 9 insertions, 2 deletions
diff --git a/resources/js/app.js b/resources/js/app.js index 40c55f6..37e0fdb 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -1 +1,8 @@ require('./bootstrap'); + +$(".mal-img").not(".mal-img-error").on("error", function() { + if ( ! $(this).hasClass("mal-img-error") ) { + this.src = $(this).data("img-src"); + } + $(this).addClass('mal-img-error'); // prevents loops +}); diff --git a/resources/views/anime.blade.php b/resources/views/anime.blade.php index 66d9373..0d00cb4 100644 --- a/resources/views/anime.blade.php +++ b/resources/views/anime.blade.php @@ -6,7 +6,7 @@ <div class="row"> <div class="col-sm-4 col-lg-3"> - <img src="{{ camo($anime->image_url) }}" class="img-fluid" style="margin-bottom: 10px;"> + <img src="{{ camo($anime->image_url) }}" class="img-fluid mal-img" data-img-src="{{ $anime->image_url }}" style="margin-bottom: 10px;"> </div> <div class="col-sm-8 col-lg-9"> <h2>Synopsis</h2> diff --git a/resources/views/list_anime.blade.php b/resources/views/list_anime.blade.php index a165d96..32ad79b 100644 --- a/resources/views/list_anime.blade.php +++ b/resources/views/list_anime.blade.php @@ -51,7 +51,7 @@ </h6> <p class="card-text"> <a href="/anime/{{ $anime->mal_id}}" title="Click for more data"> - <img src="{{ camo($anime->image_url) }}" class="img-fluid float-left-xl" style="margin-bottom: 10px; margin-right: 10px;"> + <img src="{{ camo($anime->image_url) }}" class="img-fluid float-left-xl mal-img" data-img-src="{{ $anime->image_url }}" style="margin-bottom: 10px; margin-right: 10px;"> </a> <span class="hide-synopsis-sm"> {!! replaceSpecialChars(e($anime->synopsis)) !!} |
