Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Brian

    (@brianmiyaji)

    Hey Kyle,

    I’d recommend using Advanced Custom Fields to add a new image field to the Player post type, and displaying it by modifying the single-player template in your theme.

    Then via SportsPress > Player Options page you could turn off the Photo template. This will prevent the photo from being displayed on the single player profile, but will still be used in galleries.

    Thread Starter Kyle Lawrence

    (@kylerlawrence)

    Awesome this looks quite promising. I’ve installed that and now have a new custom field called “player_head_shot” where I can upload a new image.

    I’m not too familiar with this though, Any idea what I’d have to put into the single-player.php file?

    This is what is currently in the template but I don’t know how I’d add in the “player_head_shot” image.

    <div id="post-area" <?php post_class(); ?>>
    		<?php $gd_featured_img = get_option('gd_featured_img'); if ($gd_featured_img == "true") { ?>
    			<?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { /* if post has a thumbnail */ ?>
    		<!--	<div class="post-image">
    				<?php the_post_thumbnail('post-thumb'); ?>
    			</div><!--post-image-->
    			<?php } ?>
    		<?php } ?>
    Plugin Author Brian

    (@brianmiyaji)

    Absolutely. I would comment out the_post_thumbnail('post-thumb') and put some new code above it. Depending on the Return Value set on the player_head_shot field, this code will vary slightly.

    Image Array

    <?php
    		$image = get_field('player_head_shot');
    		if( !empty($image) ): ?>
    			<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
    		<?php endif; ?>

    Image URL

    <?php
    		$image = get_field('player_head_shot');
    		if( !empty($image) ): ?>
    			<img src="<?php echo $image; ?>" />
    		<?php endif; ?>

    Based on: https://www.advancedcustomfields.com/resources/image/

    Thread Starter Kyle Lawrence

    (@kylerlawrence)

    hmm that didn’t seem to work. ??
    Return value is set to Image URL with the Image URL code.
    Any other ideas / suggestions?

    Thread Starter Kyle Lawrence

    (@kylerlawrence)

    Sorted!

    PHP was posted in the wrong area. Moved this around on the single-player page and managed to fit it into my theme exactly how it’s required. Thanks @brian.

    If anyone wants to see an example check out these links, Basically now I have a Featured Image which displays the players head shot in the player gallery.

    Upon clicking the player you then see a different image at the top of the page rather than the “Featured” image we set before.

    Can remove the other image all together if required, In this case I need it though.

    Roster Page
    Player Page

    Thread Starter Kyle Lawrence

    (@kylerlawrence)

    .

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Different Featured Image / Thumbnail for Player’ is closed to new replies.