Using wordpress generated image sizes in background (srcset)
-
To use WP’s automatically generated image sizes as background images in SS3 you have to edit the file Nextend/SmartSlider3/Slider/Feature/SlideBackground.php
and replace this
`$imageAttributes = array(
‘src’ => ResourceTranslator::toUrl($src),
‘alt’ => $alt,
‘title’ => $title,
‘loading’ => ‘lazy’,
‘style’ => ”
);`with this code
`$imageSrc = ‘https:’.ResourceTranslator::toUrl($src);
$imageId = attachment_url_to_postid($imageSrc);
$imageSrcset = wp_get_attachment_image_srcset( $imageId );
$imageSizes = wp_get_attachment_image_sizes( $imageId );$imageAttributes = array(
‘src’ => ResourceTranslator::toUrl($src),
‘srcset’ => $imageSrcset,
“sizes” => $imageSizes,
‘alt’ => $alt,
‘title’ => $title,
‘loading’ => ‘lazy’,
‘style’ => ”
);`
- The topic ‘Using wordpress generated image sizes in background (srcset)’ is closed to new replies.