Skip to content

Commit

Permalink
Add image size #443
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimp2t committed Nov 21, 2022
1 parent e29eed4 commit 24c7466
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 132 deletions.
17 changes: 9 additions & 8 deletions inc/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -1324,22 +1324,22 @@ function onepress_get_section_gallery_data() {
$post = get_post( $post_id );
if ( $post ) {
$img_thumb = wp_get_attachment_image_src( $post_id, $image_thumb_size );
if ( $img_thumb ) {
$img_thumb = $img_thumb[0];
}


$img_full = wp_get_attachment_image_src( $post_id, 'full' );
if ( $img_full ) {
$img_full = $img_full[0];
}


$alt = get_post_meta( $post_id, '_wp_attachment_image_alt', true );

if ( $img_thumb && $img_full ) {
$data[ $post_id ] = array(
'id' => $post_id,
'thumbnail' => $img_thumb,
'full' => $img_full,
'thumbnail' => $img_thumb[0],
'thumb_w' => $img_thumb[1],
'thumb_h' => $img_thumb[2],
'full' => $img_full[0],
'full_w' => $img_full[1],
'full_h' => $img_full[2],
'title' => $post->post_title,
'content' => $post->post_content,
'alt' => $alt,
Expand Down Expand Up @@ -1460,6 +1460,7 @@ function onepress_gallery_generate( $echo = true ) {
if ( $col <= 0 ) {
$col = 4;
}

switch ( $display_type ) {
case 'masonry':
$html = onepress_gallery_html( $data );
Expand Down
245 changes: 124 additions & 121 deletions section-parts/section-news.php
Original file line number Diff line number Diff line change
@@ -1,141 +1,144 @@
<?php
$id = get_theme_mod( 'onepress_news_id', 'news' );
$disable = get_theme_mod( 'onepress_news_disable' ) == 1 ? true : false;
$id = get_theme_mod('onepress_news_id', 'news');
$disable = get_theme_mod('onepress_news_disable') == 1 ? true : false;

if ( onepress_is_selective_refresh() ) {
if (onepress_is_selective_refresh()) {
$disable = false;
}

if ( ! $disable ) :

$title = get_theme_mod( 'onepress_news_title', esc_html__( 'Latest News', 'onepress' ) );
$subtitle = get_theme_mod( 'onepress_news_subtitle', esc_html__( 'Section subtitle', 'onepress' ) );
$number = absint( get_theme_mod( 'onepress_news_number', '3' ) );
$more_page = get_theme_mod( 'onepress_news_more_page', '' );
$more_link = get_theme_mod( 'onepress_news_more_link', '' );
$more_text = get_theme_mod( 'onepress_news_more_text', esc_html__( 'Read Our Blog', 'onepress' ) );
$desc = get_theme_mod( 'onepress_news_desc' );

?>
<?php if ( ! onepress_is_selective_refresh() ) { ?>
<section id="<?php if ( $id != '' ) {
echo esc_attr( $id ); } ?>" <?php do_action( 'onepress_section_atts', 'news' ); ?> class="<?php echo esc_attr( apply_filters( 'onepress_section_class', 'section-news section-padding onepage-section', 'news' ) ); ?>">
<?php } ?>
<?php do_action( 'onepress_section_before_inner', 'news' ); ?>
<div class="<?php echo esc_attr( apply_filters( 'onepress_section_container_class', 'container', 'news' ) ); ?>">
<?php if ( $title || $subtitle || $desc ) { ?>
<div class="section-title-area">
<?php if ( $subtitle != '' ) {
echo '<h5 class="section-subtitle">' . esc_html( $subtitle ) . '</h5>';} ?>
<?php if ( $title != '' ) {
echo '<h2 class="section-title">' . esc_html( $title ) . '</h2>';} ?>
<?php if ( $desc ) {
echo '<div class="section-desc">' . apply_filters( 'onepress_the_content', wp_kses_post( $desc ) ) . '</div>';
} ?>
</div>
if (!$disable) :

$title = get_theme_mod('onepress_news_title', esc_html__('Latest News', 'onepress'));
$subtitle = get_theme_mod('onepress_news_subtitle', esc_html__('Section subtitle', 'onepress'));
$number = absint(get_theme_mod('onepress_news_number', '3'));
$more_page = get_theme_mod('onepress_news_more_page', '');
$more_link = get_theme_mod('onepress_news_more_link', '');
$more_text = get_theme_mod('onepress_news_more_text', esc_html__('Read Our Blog', 'onepress'));
$desc = get_theme_mod('onepress_news_desc');

?>
<?php if (!onepress_is_selective_refresh()) { ?>
<section id="<?php if ($id != '') {
echo esc_attr($id);
} ?>" <?php do_action('onepress_section_atts', 'news'); ?> class="<?php echo esc_attr(apply_filters('onepress_section_class', 'section-news section-padding onepage-section', 'news')); ?>">
<?php } ?>
<div class="section-content">
<div class="row">
<div class="col-sm-12">
<div class="blog-entry wow slideInUp">
<?php

$cat = absint( get_theme_mod( 'onepress_news_cat' ) );
$orderby = sanitize_text_field( get_theme_mod( 'onepress_news_orderby' ) );
$order = sanitize_text_field( get_theme_mod( 'onepress_news_order' ) );
$hide_meta = sanitize_text_field( get_theme_mod( 'onepress_news_hide_meta' ), false );
$excerpt_length = absint( get_theme_mod( 'onepress_news_excerpt_length' ) );
$excerpt_type = get_theme_mod( 'onepress_news_excerpt_type', 'custom' );
if ( $hide_meta ) {
onepress_loop_set_prop( 'show_meta', false );
}

onepress_loop_set_prop( 'excerpt_length', $excerpt_length );
onepress_loop_set_prop( 'excerpt_type', $excerpt_type );

$args = array(
'posts_per_page' => $number,
'suppress_filters' => 0,
);
if ( $cat > 0 ) {
$args['category__in'] = array( $cat );
}

if ( $orderby && $orderby != 'default' ) {
$args['orderby'] = $orderby;
}

if ( $order ) {
$args['order'] = $order;
}

$query = new WP_Query( $args );

?>
<?php if ( $query->have_posts() ) : ?>

<?php /* Start the Loop */ ?>
<?php while ( $query->have_posts() ) :
$query->the_post(); ?>
<?php
<?php do_action('onepress_section_before_inner', 'news'); ?>
<div class="<?php echo esc_attr(apply_filters('onepress_section_container_class', 'container', 'news')); ?>">
<?php if ($title || $subtitle || $desc) { ?>
<div class="section-title-area">
<?php if ($subtitle != '') {
echo '<h5 class="section-subtitle">' . esc_html($subtitle) . '</h5>';
} ?>
<?php if ($title != '') {
echo '<h2 class="section-title">' . esc_html($title) . '</h2>';
} ?>
<?php if ($desc) {
echo '<div class="section-desc">' . apply_filters('onepress_the_content', wp_kses_post($desc)) . '</div>';
} ?>
</div>
<?php } ?>
<div class="section-content">
<div class="row">
<div class="col-sm-12">
<div class="blog-entry wow slideInUp">
<?php

$cat = absint(get_theme_mod('onepress_news_cat'));
$orderby = sanitize_text_field(get_theme_mod('onepress_news_orderby'));
$order = sanitize_text_field(get_theme_mod('onepress_news_order'));
$hide_meta = sanitize_text_field(get_theme_mod('onepress_news_hide_meta'), false);
$excerpt_length = absint(get_theme_mod('onepress_news_excerpt_length'));
$excerpt_type = get_theme_mod('onepress_news_excerpt_type', 'custom');
if ($hide_meta) {
onepress_loop_set_prop('show_meta', false);
}

onepress_loop_set_prop('excerpt_length', $excerpt_length);
onepress_loop_set_prop('excerpt_type', $excerpt_type);

$args = array(
'posts_per_page' => $number,
'suppress_filters' => 0,
);
if ($cat > 0) {
$args['category__in'] = array($cat);
}

if ($orderby && $orderby != 'default') {
$args['orderby'] = $orderby;
}

if ($order) {
$args['order'] = $order;
}

$query = new WP_Query($args);

?>
<?php if ($query->have_posts()) : ?>

<?php /* Start the Loop */ ?>
<?php while ($query->have_posts()) :
$query->the_post(); ?>
<?php
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'template-parts/content', 'list' );
?>

<?php endwhile; ?>
<?php else : ?>
<?php get_template_part( 'template-parts/content', 'none' ); ?>
<?php endif;
get_template_part('template-parts/content', 'list');
?>

<?php endwhile; ?>
<?php else : ?>
<?php get_template_part('template-parts/content', 'none'); ?>
<?php endif;


if ($hide_meta) {
onepress_loop_remove_prop('show_meta');
}

onepress_loop_remove_prop('excerpt_length');
onepress_loop_remove_prop('excerpt_type');

$link = '';
$label = '';

if ($more_page) {
$page = get_post($more_page);
if ($page) {
$link = get_permalink($page);
if (!$more_text) {
$label = $page->post_title;
}
}
}

if (!$link) {
$link = $more_link;
}

if (!$label) {
$label = $more_text;
}

if ($link != '' && $label != '') {
?>
<div class="all-news">
<a class="btn btn-theme-primary-outline" href="<?php echo esc_url($link); ?>"><?php echo esc_html($label); ?></a>
</div>
<?php } ?>


if ( $hide_meta ) {
onepress_loop_remove_prop( 'show_meta' );
}

onepress_loop_remove_prop( 'excerpt_length' );
onepress_loop_remove_prop( 'excerpt_type' );

$link = '';
$label = '';

if ( $more_page ) {
$page = get_post( $more_page );
if ( $page ) {
$link = get_permalink( $page );
if ( ! $more_text ) {
$label = $page->post_title;
}
}
}

if ( ! $link ) {
$link = $more_link;
}

if ( ! $label ) {
$label = $more_text;
}

if ( $link != '' && $label != '' ) {
?>
<div class="all-news">
<a class="btn btn-theme-primary-outline" href="<?php echo esc_url( $link ); ?>"><?php echo esc_html( $label ); ?></a>
</div>
<?php } ?>

</div>
</div>
</div>

</div>
</div>
</div>
<?php do_action( 'onepress_section_after_inner', 'news' ); ?>
<?php if ( ! onepress_is_selective_refresh() ) { ?>
</section>
<?php do_action('onepress_section_after_inner', 'news'); ?>
<?php if (!onepress_is_selective_refresh()) { ?>
</section>
<?php } ?>
<?php endif;
wp_reset_postdata();
4 changes: 2 additions & 2 deletions section-parts/section-team.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class="<?php echo esc_attr(apply_filters('onepress_section_class', 'section-team

$image_attributes = wp_get_attachment_image_src( $user_id['id'], 'onepress-small' );
$image_alt = get_post_meta( $user_id['id'], '_wp_attachment_image_alt', true);

if ( $image_attributes ) {
$image = $image_attributes[0];
$data = get_post( $user_id['id'] );
Expand All @@ -58,7 +58,7 @@ class="<?php echo esc_attr(apply_filters('onepress_section_class', 'section-team
<?php if ( $link ) { ?>
<a href="<?php echo esc_url( $link ); ?>">
<?php } ?>
<img src="<?php echo esc_url( $image ); ?>" alt="<?php echo $image_alt; ?>">
<img src="<?php echo esc_url( $image ); ?>" alt="<?php echo $image_alt; ?>" width="<?php echo esc_attr($image_attributes[1]); ?>" height="<?php echo esc_attr($image_attributes[2]); ?>">
<?php if ( $link ) { ?>
</a>
<?php } ?>
Expand Down
2 changes: 1 addition & 1 deletion template-parts/content-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'onepress-blog-small' );
} else {
echo '<img alt="" src="' . get_template_directory_uri() . '/assets/images/placholder2.png">';
echo '<img alt="" src="' . get_template_directory_uri() . '/assets/images/placholder2.png" width="300" height="150">';
}
?>
</a>
Expand Down

0 comments on commit 24c7466

Please sign in to comment.