diff --git a/src/assets/scss/_post.scss b/src/assets/scss/_post.scss index defbb39..52840f1 100644 --- a/src/assets/scss/_post.scss +++ b/src/assets/scss/_post.scss @@ -614,7 +614,9 @@ align-items: center; flex-direction: column; min-height: 10vh; - + img { + width: auto; + } > iframe, img.attachment-large { display: block; height: auto; diff --git a/src/functions/customizer.php b/src/functions/customizer.php index debe3a2..4e11c5c 100644 --- a/src/functions/customizer.php +++ b/src/functions/customizer.php @@ -788,6 +788,31 @@ function tainacan_customize_register( $wp_customize ) { ) ); } + if (version_compare(TAINACAN_VERSION, '0.17RC') >= 0) { + /** + * Allows setting max heigth for the document --------------------------------------------------------- + */ + $wp_customize->add_setting( 'tainacan_single_item_document_max_height', array( + 'type' => 'theme_mod', + 'capability' => 'edit_theme_options', + 'default' => 60, + 'transport' => 'refresh', + 'sanitize_callback' => 'sanitize_text_field' + ) ); + $wp_customize->add_control( 'tainacan_single_item_document_max_height', array( + 'type' => 'number', + 'priority' => 2, // Within the section. + 'section' => 'tainacan_single_item_page', + 'label' => __( 'Document maximum height (vh)', 'tainacan-interface' ), + 'description' => __( 'Set the maximum height for the document. The unit of measure is relative to the screen, for example: 60vh is 60% of the height of the browser window height.', 'tainacan-interface' ), + 'input_attrs' => array( + 'min' => 10, + 'max' => 150, + 'step' => 5 + ), + ) ); + } + /** * Adds options to display or not the thumbnail on items page. */ @@ -994,7 +1019,6 @@ function tainacan_customize_register( $wp_customize ) { 'fallback_refresh' => true ) ); - /** * Adds section to settings related to search control . --------------------------------------------------------- @@ -2467,6 +2491,42 @@ function tainacan_single_item_metadata_columns_count_output() { } add_action( 'wp_head', 'tainacan_single_item_metadata_columns_count_output'); + +/** + * Enqueues front-end CSS for the single item page document max-height. + * + * @since Tainacan Theme + * + * @see wp_add_inline_style() + */ +function tainacan_single_item_document_max_height_output() { + $max_document_height = get_theme_mod( 'tainacan_single_item_document_max_height', 60 ); + + // If the value is not a number, return early. + if ( !is_numeric( $max_document_height ) ) { + return; + } + + $css = ' + /* Custom Settings for Single Item Page Document Height */ + + .tainacan-single-post .tainacan-content.single-item-collection .single-item-collection--document img, + .tainacan-single-post .tainacan-content.single-item-collection .single-item-collection--document video, + .tainacan-single-post .tainacan-content.single-item-collection .single-item-collection--document audio, + .tainacan-single-post .tainacan-content.single-item-collection .single-item-collection--document iframe { + max-height: ' . $max_document_height . '%; + max-height: ' . $max_document_height . 'vh; + } + .tainacan-single-post .tainacan-content.single-item-collection .tainacan-media-component { + --tainacan-media-main-carousel-height: ' . $max_document_height . '%; + --tainacan-media-main-carousel-height: ' . $max_document_height . 'vh; + } + '; + + echo ''; +} +add_action( 'wp_head', 'tainacan_single_item_document_max_height_output'); + /** * Enqueues front-end CSS for the items page fixed filters logic. *