This pastie has both the functions.php and home.php code for review. For reference, my goal is to make the image follow the same rules found in this jsfiddle.
My goal with the function is to pull the first image from a post and put it above the summary on my blog’s homepage. I’ve been able to pull the image from the post, but it isn’t following the responsive class I used in line 60. Is it that I am pulling the image itself and not the URL? How can I adjust my function to make this work? Outside of database connections and form validation, I am a complete php beginner.
Please see jsfiddle and pastie for code
Use Post_Thumbnails instead.
In your functions.php add the following:
add_theme_support( 'post-thumbnails' );
This will enable the Featured Image meta box in the sidebar of your posts and pages. You will need to set this for posts. Instead of adding an image to your post’s content, you can set your desired image as the featured image.
Update your home.php to the following:
has_post_thumbnail()
checks to see if the current$post
has a featured image set.the_post_thumbnail()
outputs the image tag. This functions takes a size as it’s first parameter. We are setting this to large as it should satisfy your layout.The second parameter is an array of attributes. We are able to add additional classes to the image using this parameter.