Use this. you will need to call thumbnail sizes.
$small_regular = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID), 'small_regular' );
$big_regular = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID), 'big_regular' );
echo "<style type="text/css">";
echo ".entry-featured-image { background-image: url('" . $big_regular[0] . "'); }";
echo "@media screen and (max-width:48em) { .entry-featured-image { background-image: url('" . $small_regular[0] . "'); } }";
echo "</style>";
Related Posts:
- How do I work with responsive images in WordPress? (img srcset/sizes)
- The the_post_thumbnail without srcset?
- Get the first image from post content (eg.: hotlinked images)
- How can I set image sizes and still have responsive images using the srcset attribute?
- How to add a 2nd “featured image” to a post?
- Excess White Space Above Admin Bar on Frontend Using Twitter Bootstrap
- How to change post thumbnail title and alt attributes to post title?
- Featured Image in 4.4 should be larger on mobile device
- How to use the responsive images feature from WP 4.4 in your themes
- Unexpected width and srcset attributes for the_post_thumbnail();
- How to handle thumbnails
- Change display of featured image for pages in twenty seventeen theme
- How to set dimensions of the post thumbnails (featured images)
- How to regenerate thumbnails when they’re stored on S3
- Cannot get full thumbnail size using the_post_thumbnail
- What tags should be used for themes to show the type of layout?
- Meta tag viewport
- How to make wordpress theme iframe responsive
- Featured Images are not able to be set
- Display recent posts with thumbnail
- Reasons why all thumbnail sizes aren’t working
- How do I Add images uploaded in the post to a default custom field
- How do I build a post_thumbnail based archive? [closed]
- Responsive Images – crop don’t seem to work
- How do I turn a post thumbnail into a background image?
- Reactor Theme: Prevent Post Thumb on Post
- Featured Image meta box not showing up
- How do I remove inline style in featured image markup?
- Custom image size vs CSS sizing
- Change Responsive Images Maximum Width of 1600px
- Set a featured image as a replacement to the header image
- Dynamic Post Thumbnail →
- Issue on Getting Custom post type Thumbnail’s URL
- How To Pick Custom Size Of Uploaded Image In Theme Via the_post_thumbnail();?
- How to disable thumbnail filter for a specific template part or image size?
- the_post_thumbnail() get the URL to the “medium” sized image
- Full width featured thumbnail
- Change Image Sizes for Mobile Theme
- How can I get the featured image or the first image for a post/page and display it as a banner?
- How to make excerpt image be full size instead of thumbnail?
- How can I scale down the width of images in bulk that are embedded in posts throughout the site?
- Add image URL automatically to custom field?
- theme directory fallback image outputs url and not the image
- Created blank theme for REST API, featured image not appearing on admin side
- add class to all images inside the content
- Menu is in Reversed order
- Responsive Images with art direction
- Should I detect the device or the page first?
- Full width thumbnail
- Featured Image Module Randomly Disappears
- Single Featured Image Repeating
- FitVid not working for iframes on particular theme install
- Any disadvandages if I style the wordpress align classes without img and .wp-caption prefix
- apply_filters to featured image
- Set start page depending on screen width [closed]
- Show post thumbnail only if it exists using timthumb
- How to resize video lightbox popup in wordpress? [closed]
- Display Page featured Image as well as Posts featured Image
- Elementor Pro and Astra have different breakpoints – how to salvage?
- Correct way to make a custom block theme responsive
- I want to resize post featured image without cropping image. How?
- WP “optimizing” PNGs into thumbnails 5X larger than originals – FIX
- optimized PNGs 5X larger than originals
- No src and sizes attributes present on WordPress thumbnail images; the smallest image size is loaded irregardless of viewport size
- Menu items description? Custom Walker for wp_nav_menu()
- How to define and link full path to css located at a random folder on header.php
- Sizing screenshot.png without losing aspect ratio
- Software for WordPress Theme and Plugin Development? [closed]
- When to use is_home() vs is_front_page()?
- What is the preferred way to add custom javascript files to the site?
- Get the blog page URL set in Options
- How to create .pot files with POedit?
- How do I get the theme URL in PHP?
- Why when I submit a form in wordpress it loads a 404 page though URL is correct
- What is the constant WP_USE_THEMES for?
- Worthwhile to restrict direct access of theme files?
- How Do I Protect My Premium WordPress App Theme from Copying?
- How to detect mobile devices and present them a specific theme?
- Using wp_add_inline_style without a stylesheet
- How to add posts to custom menus?
- WordPress Theme Preview Image
- How To extend WP_Customize_Control
- What is the difference between front-page.php and home.php? [duplicate]
- How can I get page slug
- Does the functions.php file ever get called during an AJAX call? Debug AJAX
- When to use _e and __ for the translation?
- What is a Theme textdomain?
- How to show a custom meta box on the “Quick Edit” screen?
- How to add CSS class to custom logo?
- How to add custom css file in theme?
- How important is it to enqueue a theme’s stylesheet?
- CSS not updating in browser when I change it
- Display Search Result Count
- wp_nav_menu(), how to change class?
- theme path in javascript file
- Is wp_is_mobile() effective?
- Display Menu Name using wp_nav_menu
- Making update notification functionality for my themes
- What questions do you ask when asked to give an estimate on theme development?
- How to remove dashicons.min.css from frontend?