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?
- Menu items description? Custom Walker for wp_nav_menu()
- Sizing screenshot.png without losing aspect ratio
- “Quick Edit” > update clears out my custom meta values
- Add default Backgrounds
- Page template in two level deep folder
- Worthwhile to restrict direct access of theme files?
- Use of undefined constant FS_CHMOD_DIR – assumed ‘FS_CHMOD_DIR’
- How to remove header images from all pages except the home page? skeleton theme
- Why use while over if in single wordpress posts?
- wp_enqueue_script being ignored in custom theme
- First completely customized theme, where should I start?
- Theme Options page not showing up in admin menu
- Cutomize Colors utility: How to add more configurable colors to a theme
- How to prepare the HTML for WordPress [closed]
- Add theme support for post thumbnail isn’t working from theme class
- How can I alter the display of category listings via sidebar.php?
- Need advice > converting category assignments to custom post meta values
- How to edit theme functions file to modify pagination?
- Divi – How can we show background video on mobile
- Calling post_exists() causes white screen in after_setup_theme
- Efficiency of wp_options vs a new table
- CSS class on last post in loop ( custom query )
- add_theme_support( ‘admin-bar’ ) causes fatal error
- how to make wordpress change the title and keep page name?
- Place title (in correct place) above image with opaque background [closed]
- Generate responsive post thumbnails of same size
- How do I implement jPanelMenu?
- When trying to set title, not sure how to edit it for different pages
- static front page ONLY for certain themes?
- How to add cropped custom header image?
- Alter shop page lay-out in OceanWP theme
- the_content() is getting null in Preview Debug
- Different WP Rest API custom endpoints across different themes
- How to set different localization file for different users?
- How to add an import widgets functionality to wordpress themes without a plugin
- Change site title color on individual pages
- Bestway to write php functions
- How to change order of elements using a child theme
- My theme is full of error messages in the “Customize” screen, but nowhere else