Browse Source

Mise a jour de AdaptiveImages

master
Cerdic 6 months ago
parent
commit
590cfe0d2c
  1. 17
      lib/AdaptiveImages/AdaptiveImages.php

17
lib/AdaptiveImages/AdaptiveImages.php

@ -2,7 +2,7 @@
/**
* AdaptiveImages
*
* @version 2.1.0
* @version 2.2.0
* @copyright 2013-2020
* @author Nursit
* @licence GNU/GPL3
@ -341,9 +341,9 @@ class AdaptiveImages {
$minwidthdesktop = $this->maxWidthMobileVersion + 0.5;
$base_style = "<style type='text/css'>"
."img.adapt-img,.lazy img.adapt-img{max-width:100%;height:auto;}"
.".adapt-img-wrapper {display:block;max-width:100%;position:relative;background-position:center;-webkit-background-size:100% auto;-webkit-background-size:cover;background-size:cover;background-repeat:no-repeat;line-height:1px;overflow:hidden}"
.".adapt-img-wrapper.intrinsic::before{content:'';display:block;height:0;width:100%;}.adapt-img-wrapper.intrinsic img{position:absolute;left:0;top:0;width:100%;height:auto;}"
."@media (min-width:{$minwidthdesktop}px){.adapt-img-wrapper.intrinsic-desktop::before{content:'';display:block;height:0;width:100%;}.adapt-img-wrapper.intrinsic-desktop img{position:absolute;left:0;top:0;width:100%;height:auto;}}"
.".adapt-img-wrapper {display:inline-block;max-width:100%;position:relative;background-position:center;background-size:cover;background-repeat:no-repeat;line-height:1px;overflow:hidden}"
.".adapt-img-wrapper.intrinsic{display:block}.adapt-img-wrapper.intrinsic::before{content:'';display:block;height:0;width:100%;}.adapt-img-wrapper.intrinsic img{position:absolute;left:0;top:0;width:100%;height:auto;}"
."@media (min-width:{$minwidthdesktop}px){.adapt-img-wrapper.intrinsic-desktop{display:block}.adapt-img-wrapper.intrinsic-desktop::before{content:'';display:block;height:0;width:100%;}.adapt-img-wrapper.intrinsic-desktop img{position:absolute;left:0;top:0;width:100%;height:auto;}}"
.".adapt-img-background{width:100%;height:0}"
."@media print{html .adapt-img-wrapper{background:none}"
."</style>\n";
@ -360,7 +360,7 @@ JS;
case '3layers':
default:
$base_style = "<style type='text/css'>"."img.adapt-img,.lazy img.adapt-img{max-width:100%;height:auto;}img.adapt-img.blur{filter:blur(5px)}"
.".adapt-img-wrapper,.adapt-img-wrapper::after{display:block;max-width:100%;position:relative;-webkit-background-size:100% auto;-webkit-background-size:cover;background-size:cover;background-repeat:no-repeat;line-height:1px;overflow:hidden}"
.".adapt-img-wrapper,.adapt-img-wrapper::after{display:block;max-width:100%;position:relative;background-size:cover;background-repeat:no-repeat;line-height:1px;overflow:hidden}"
.".adapt-img-background{width:100%;height:0}.adapt-img-background::after{display:none;width:100%;height:0;}"
."html body .adapt-img-wrapper.lazy,html.lazy body .adapt-img-wrapper,html body .adapt-img-wrapper.lazy::after,html.lazy body .adapt-img-wrapper::after{background-image:none}"
.".adapt-img-wrapper::after{position:absolute;top:0;left:0;right:0;bottom:0;content:\"\"}"
@ -881,7 +881,7 @@ JS;
*/
protected function imgAdaptiveMarkup($img, $bkptImages, $width, $height, $extension, $maxWidth1x, $sizes=null, $asBackground = false){
$class = $this->tagAttribute($img, "class");
if (strpos($class, "adapt-img")!==false){
if (!$width or strpos($class, "adapt-img")!==false){
return $img;
}
ksort($bkptImages);
@ -943,9 +943,6 @@ JS;
* @return string
*/
protected function imgAdaptiveSrcsetMarkup($img, $fallback_file, $fallback_class, $bkptImages, $width, $height, $extension, $maxWidth1x, $maxWidthMobile=null, $sizes = null){
if (!intval($width)) {
return '';
}
$originalClass = $class = $this->tagAttribute($img,"class");
$intrinsic = "";
if (strpos(" $class "," intrinsic ") !== false) {
@ -1072,7 +1069,7 @@ JS;
$img = $this->setTagAttribute($img,"sizes",$sizes_rule);
// markup can be adjusted in hook, depending on style and class
$markup = "<picture class=\"adapt-img-wrapper{$intrinsic} $cid $extension\" style=\"background-image:url($fallback_file)\">\n$sources\n$img</picture>";
$markup = "<picture class=\"adapt-img-wrapper{$intrinsic} $cid $extension\" style=\"".($intrinsic ? "max-width:{$maxWidth1x}px;":"")."background-image:url($fallback_file)\">\n$sources\n$img</picture>";
$markup = $this->imgMarkupHook($markup,$originalClass,$originalStyle);
if ($style) {

Loading…
Cancel
Save