| 1 |
<?php |
| 2 |
|
| 3 |
// Exit if accessed directly. |
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Displays the campaign thumbnail. |
| 10 |
* |
| 11 |
* @author WP Charitable LLC |
| 12 |
* @package Charitable/Templates/Campaign |
| 13 |
* @since 1.0.0 |
| 14 |
* @version 1.8.2 |
| 15 |
* @version 1.8.3.7 - added force_featured_thumbnail parameter/filter. |
| 16 |
* @version 1.8.8.6 |
| 17 |
*/ |
| 18 |
|
| 19 |
$charitable_campaign = $view_args['campaign']; |
| 20 |
$charitable_force_featured_thumbnail = apply_filters( 'charitable_campaign_loop_featured_thumbnail', empty( $view_args['force_featured_thumbnail'] ) ? false : true ); |
| 21 |
|
| 22 |
// determine if this is a legacy campaign, or a new campaign built with the visual editor. |
| 23 |
if ( ! function_exists( 'charitable_is_campaign_legacy' ) ) : |
| 24 |
if ( has_post_thumbnail( $charitable_campaign->ID ) ) : |
| 25 |
echo get_the_post_thumbnail( $charitable_campaign->ID, apply_filters( 'charitable_campaign_loop_thumbnail_size', 'medium' ) ); |
| 26 |
endif; |
| 27 |
elseif ( charitable_is_campaign_legacy( $charitable_campaign ) || $charitable_force_featured_thumbnail ) : |
| 28 |
$charitable_thumbnail_id = get_post_thumbnail_id( $charitable_campaign->ID ); |
| 29 |
if ( $charitable_thumbnail_id ) : |
| 30 |
echo wp_get_attachment_image( $charitable_thumbnail_id, apply_filters( 'charitable_campaign_loop_thumbnail_size', 'medium' ) ); |
| 31 |
endif; |
| 32 |
return; |
| 33 |
elseif ( function_exists( 'charitable_find_photo_in_campaign_settings' ) ) : |
| 34 |
$charitable_campaign_settings = get_post_meta( $charitable_campaign->ID, 'campaign_settings_v2', true ); |
| 35 |
$charitable_media_info = charitable_find_photo_in_campaign_settings( $charitable_campaign_settings ); |
| 36 |
if ( ! empty( $charitable_media_info['media_id'] ) ) { |
| 37 |
$charitable_image_attributes = wp_get_attachment_image_src( $charitable_media_info['media_id'], apply_filters( 'charitable_campaign_loop_thumbnail_size', 'medium' ) ); |
| 38 |
if ( ! empty( $charitable_image_attributes ) ) : ?> |
| 39 |
<img src="<?php echo esc_url( $charitable_image_attributes[0] ); ?>" width="<?php echo esc_html( $charitable_image_attributes[1] ); ?>" height="<?php echo esc_html( $charitable_image_attributes[2] ); ?>" /> |
| 40 |
<?php |
| 41 |
endif; |
| 42 |
} |
| 43 |
endif; |
| 44 |
|