content-thumbnail.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /**
  3. * Template part for displaying the content featured image.
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
  6. *
  7. * @package Pen
  8. */
  9. if ( ! post_password_required() && ! is_attachment() && has_post_thumbnail() ) {
  10. $pen_post_id = get_the_ID();
  11. if ( is_singular() ) {
  12. $thumbnail_display = get_post_meta( $pen_post_id, 'pen_content_thumbnail_display_override', true );
  13. if ( ! $thumbnail_display || 'default' === $thumbnail_display ) {
  14. $thumbnail_display = pen_option_get( 'content_thumbnail_display' );
  15. }
  16. if ( $thumbnail_display && 'no' !== $thumbnail_display ) {
  17. $thumbnail_size = get_post_meta( $pen_post_id, 'pen_content_thumbnail_resize_override', true );
  18. if ( ! $thumbnail_size || 'default' === $thumbnail_size ) {
  19. $thumbnail_size = pen_option_get( 'content_thumbnail_resize' );
  20. }
  21. if ( 'none' === $thumbnail_size ) {
  22. if ( 'image' === get_post_type() ) {
  23. $thumbnail_size = 'large';
  24. } else {
  25. $thumbnail_size = 'medium';
  26. }
  27. }
  28. $animation_reveal = get_post_meta( $pen_post_id, 'pen_content_thumbnail_animation_reveal_override', true );
  29. if ( ! $animation_reveal || 'default' === $animation_reveal ) {
  30. $animation_reveal = pen_option_get( 'content_thumbnail_animation_reveal' );
  31. }
  32. $classes = trim(
  33. implode(
  34. ' ',
  35. array_filter(
  36. array(
  37. 'post-thumbnail',
  38. 'pen_thumbnail_size_' . $thumbnail_size,
  39. $animation_reveal ? 'pen_custom_animation_' . $animation_reveal : '',
  40. )
  41. )
  42. )
  43. );
  44. ?>
  45. <div class="<?php echo esc_attr( $classes ); ?>">
  46. <?php
  47. the_post_thumbnail( $thumbnail_size );
  48. ?>
  49. </div><!-- .post-thumbnail -->
  50. <?php
  51. }
  52. } else {
  53. $thumbnail_display = get_post_meta( $pen_post_id, 'pen_list_thumbnail_display_override', true );
  54. if ( ! $thumbnail_display || 'default' === $thumbnail_display ) {
  55. $thumbnail_display = pen_option_get( 'list_thumbnail_display' );
  56. }
  57. if ( $thumbnail_display && 'no' !== $thumbnail_display ) {
  58. $thumbnail_size = get_post_meta( $pen_post_id, 'pen_list_thumbnail_resize_override', true );
  59. if ( ! $thumbnail_size || 'default' === $thumbnail_size ) {
  60. $thumbnail_size = pen_option_get( 'list_thumbnail_resize' );
  61. }
  62. if ( 'none' === $thumbnail_size || 'masonry' === pen_option_get( 'list_type' ) ) {
  63. $thumbnail_size = 'large';
  64. }
  65. $animation_reveal = get_post_meta( $pen_post_id, 'pen_list_thumbnail_animation_reveal_override', true );
  66. if ( ! $animation_reveal || 'default' === $animation_reveal ) {
  67. $animation_reveal = pen_option_get( 'list_thumbnail_animation_reveal' );
  68. }
  69. $classes = trim(
  70. implode(
  71. ' ',
  72. array_filter(
  73. array(
  74. 'post-thumbnail',
  75. 'pen_thumbnail_size_' . $thumbnail_size,
  76. $animation_reveal ? 'pen_custom_animation_' . $animation_reveal : '',
  77. )
  78. )
  79. )
  80. );
  81. ?>
  82. <a class="<?php echo esc_attr( $classes ); ?>" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1">
  83. <?php
  84. the_post_thumbnail( $thumbnail_size );
  85. ?>
  86. </a>
  87. <?php
  88. }
  89. }
  90. }