set image size on attachment page

Community Forums Forums Design Tips and Tricks set image size on attachment page

This topic is: not resolved

This topic contains 6 replies, has 4 voices, and was last updated by  rfmeier 9 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #45130

    mmjaeger
    Participant
    Post count: 65

    Hello
    I’d like to use a different image size on the attachment page – it looks like WP/Genesis is taking the medium image – how can I do that?

    Thanks

    #45133

    rfmeier
    Participant
    Post count: 597

    Hello,

    Good question. I had to dig around WordPress to find out exactly where this was being specified. You can adjust this with the WordPress ” filter. Hereis what I came up with;

    I hope this helps.


    #79566

    Cleo3
    Participant
    Post count: 10

    Thank you! I tried it and it works perfectly!

    This problem has been driving me nuts for ages – finally took the time to search for an answer. I’m off to paste this into a bunch of sites! Thank you so much!

    #86540

    Bart van Maanen
    Participant
    Post count: 26

    This looks like the fix I’m looking for. However, I pasted into the bottom of functions.php of the Minimum Pro theme and it disabled the whole file. Do I need to create a seperate attachment.php file to add to the Child Theme?

    Or is it something with the //* -tags

    I’m trying to use it in conjuction withe these styling options for the attachment pages:

    
    //* Customize the post info function
    add_filter( 'genesis_post_info', 'sp_post_info_filter' );
    function sp_post_info_filter($post_info) {
    if ( !is_attachment() ) {
    	$post_info = '[post_date] by [post_author_posts_link] [post_comments] [post_edit]';
    	return $post_info;
    }}
    
    //* Customize the post meta function
    add_filter( 'genesis_post_meta', 'sp_post_meta_filter' );
    function sp_post_meta_filter($post_meta) {
    if ( !is_attachment() ) {
    	$post_meta = '[post_categories before="Filed Under: "] [post_tags before="Tagged: "]';
    	return $post_meta;
    }}
    #86559

    rfmeier
    Participant
    Post count: 597

    Change //* to just //

    The //* is expecting a */ closure.


    #86669

    Bart van Maanen
    Participant
    Post count: 26

    I had to comment out the following, and then it worked;

    add_filter( 'prepend_attachment', 'custom_prepend_attachment' );
    
    // * Callback for WordPress 'prepend_attachment' filter.
    // * 
    // * Change the attachment page image size to 'full'
    // * 
    // * @package WordPress
    // * @category Attachment
    // * @see wp-includes/post-template.php
    // * 
    // * @param string $attachment_content the attachment html
    // * @return string $attachment_content the attachment html
    
    function custom_prepend_attachment( $attachment_content ){
            
            // set the attachment image size to 'full'
            $attachment_content = sprintf( '<p>%s</p>', wp_get_attachment_link(0, 'full', false) );
            
            // return the attachment content
            return $attachment_content;
            
    }
    

    Is that okay?
    Can I also add some code here to prevent the image to link any further. See: http://www.thomaselshuis.nl/wpsite/portfolio/travelogue/attachment/gr-twilight-horizon/

    Thanks!

    #86701

    rfmeier
    Participant
    Post count: 597

    Bart,

    It will not hurt anything. Good luck.


Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.