• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Is my custom code making use of the srcset functionality?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Is my custom code making use of the srcset functionality?

This topic is: not resolved

Tagged: featured image, srcset

  • This topic has 3 replies, 3 voices, and was last updated 9 years, 11 months ago by Victor Font.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • July 26, 2016 at 5:11 pm #190245
    lvvvvvl
    Participant

    Hello,

    I'm using a function code to inject the featured image into the genesis post entry but I wanted to make sure I'm taking advantage of the ' srcset ' element to as to deliver mobile optimized image sizes.

    This is the code I'm using:

    // Position Featured Image
    add_action( 'genesis_entry_content', 'themeprefix_featured_image', 1 );
    function themeprefix_featured_image() {
    	$image = genesis_get_image( array( 
    			'format'  => 'html',
    			'size'    => 'full',
    			'context' => '',
    			'attr'    => array ( 'class' => 'aligncenter' ), 
    		) );
    	if ( is_page() || is_single()) {
    		if ( $image ) {
    			printf( '<div class="featured-image-class">%s</div>', $image );
    		}
    	}
    }

    How would I go about adding the 'srcset' to that code so it delivers the right size image depending on display screen?

    Thank you.

    July 26, 2016 at 7:00 pm #190249
    Brad Dalton
    Participant

    Would need to inspect the source code. Link to your site please.


    Tutorials for StudioPress Themes.

    July 26, 2016 at 7:11 pm #190250
    lvvvvvl
    Participant

    Thanks for your response Brad.

    I'm currently working on it on a local pc but this is the code that renders in the featured image div: http://pastebin.com/ARaCqrJy

    I can see it render the srcset info with a variety of sizes, but being unfamiliar with srcset I'm not sure if that's correctly rendered.

    July 27, 2016 at 6:19 am #190288
    Victor Font
    Moderator

    Srcset is rendered by WordPress, not Genesis or your code. WordPress renders it correctly.


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble