• Resolved Khürt Williams

    (@khurtwilliams)


    I modified the post content width of the Twenty Thireen theme in the style sheet (style.css) to 960 on my blog.

    However, I can’t seem to get the images to scale to fit the content area. All images on the site were 960px wide before switching to Twenty Thirteen.

    I’ve modified the themes functions file (functions.php) as follows

    /**
     * Adjusts content_width value for video post formats and attachment templates.
     *
     * @since Twenty Thirteen 1.0
     *
     * @return void
     */
    function twentythirteen_content_width() {
    	global $content_width;
    
    	if ( is_attachment() )
    		/** $content_width = 724; */
    		$content_width = 960;
    	elseif ( has_post_format( 'audio' ) )
    		$content_width = 484;
    }
    /**
     * Prints the attached image with a link to the next attached image.
     *
     * @since Twenty Thirteen 1.0
     *
     * @return void
     */
    function twentythirteen_the_attached_image() {
    	$post                = get_post();
    	/** $attachment_size     = apply_filters( 'twentythirteen_attachment_size', array( 724, 724 ) ); **/
    	$attachment_size     = apply_filters( 'twentythirteen_attachment_size', array( 960, 960) );
    	$next_attachment_url = wp_get_attachment_url();

    This doesn’t seem to work. What am I doing wrong?

Viewing 16 replies (of 16 total)
  • This may have helped you – it’s from the Twenty thirteen functions.php file …

    /*
     * Set up the content width value based on the theme's design.
     *
     * @see twentythirteen_content_width() for template-specific adjustments.
     */
    if ( ! isset( $content_width ) )
    	$content_width = 604;

    Thanks to Binary Moon for the heads-up! Ben suggests it only effects images uploaded through the Uploader and embed shortcodes, but it’s probably good practice to set it correctly for child theme templates anyway.
    Also, it’s pluggable (as per the Codex suggestions when developing themes), so that means you can simply insert the same code in your own child theme functions.php, change the value, and it will override the default value.

Viewing 16 replies (of 16 total)
  • The topic ‘How to Modify the Width of the WordPress [Twenty Thirteen Theme] Post Image?’ is closed to new replies.