0

I have a custom page called "produtos", and i have created a php file for showing the image in frontpage, but i desire to load only resized images, not raw image rezised.

My code is:

<?php
/**
 * Template Name: Page Produtos
 */
get_header();

get_template_part( 'partials/title_box' );

if ( get_post_meta( get_the_ID(), 'show_breadcrumbs', true ) != 'no' ) {
    get_template_part( 'partials/breadcrumbs' );
}
?>

<?php
if ( have_posts() ) {
    while ( have_posts() ) {
        the_post();
        get_template_part( 'partials/content', 'page' );
    }
    get_template_part( 'partials/paginate' );
} else {
    get_template_part( 'content', 'none' );
}
?>

<?php
    $args = array(
                'post_type'      => 'produto',
        'posts_per_page' => -1,
                'meta_query'         => array(
                    array(
                        'key'     => 'wpcf-tipo',
                        'value'   => ((isset($_GET['tipo']) && ($_GET['tipo']=='menina' || $_GET['tipo']=='menino'))?$_GET['tipo']:array('menino', 'menina')),
                        'compare' => 'LIKE',
                    ),
                ),
        'orderby' => 'meta_value_num',
                'meta_key' => 'wpcf-peso',
                'order'     => 'ASC'
    );
    $the_query = new WP_Query($args);
?>

<h3>Filtrar:</h3>
<ul id="products-filter">
    <li class="tudo">
        <a href="/produtos">TODOS</a>
    </li>
    <li class="meninas">
        <a href="/produtos?tipo=menina">MENINAS</a>
    </li>   
    <li class="meninos">
        <a href="/produtos?tipo=menino">MENINOS</a>
    </li>
</ul>

<?php if ( $the_query->have_posts() ): ?>
    <div class="row" id="products">
        <?php while ( $the_query->have_posts() ): ?>
            <?php $the_query->the_post(); ?>
            <div class="col-xs-12 col-sm-4 col-md-3 product" alt="<?php get_the_title() ?>" title="<?php get_the_title() ?>">
                <div class="change">
                    <i class="fa fa-undo" aria-hidden="true"></i>
                </div>
                <a href="<?php echo get_permalink() ?>">
                    <?php if(types_render_field('lancamento')=="Sim"): ?>
                    <div class="new <?php echo strtolower(types_render_field('tipo')) ?>">
                        <h1>Lançamento</h1>
                    </div>
                    <?php endif; ?>
                    <div class="img top">
                        <img alt="<?php get_the_title() ?>" title="<?php get_the_title() ?>" src="<?php echo types_render_field("logo", array("width"=>"200","height"=>"200", "raw" => "true")); ?>" class="img-responsive"/>
                    </div>
                    <div class="img botton">
                        <img alt="<?php get_the_title() ?>" title="<?php get_the_title() ?>" src="<?php echo types_render_field("miniatura", array("size"=>"medium", "raw" => "true")); ?>" class="img-responsive"/>
                    </div>
                </a>
            </div>
        <?php endwhile; ?>
    </div>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
<?php get_footer(); ?>


<script type="text/javascript">
    jQuery("#products .product .change").click(function(){ 
        jQuery(this).next("a").children(".img.top").toggleClass("noopacity");
    });    
</script>

In line 71:

<div class="img top">

and in 74:

<div class="img botton">

The code for display miniature images is inserted. And none of my div codes worked....

<img alt="<?php get_the_title() ?>" title="<?php get_the_title() ?>" src="<?php echo types_render_field("logo", array("width"=>"200","height"=>"200", "raw" => "true")); ?>" class="img-responsive"/>
<img alt="<?php get_the_title() ?>" title="<?php get_the_title() ?>" src="<?php echo types_render_field("miniatura", array("size"=>"medium", "raw" => "true")); ?>" class="img-responsive"/>

But loads the raw image, in original size, not the custom size, as you can see in screenshot:

enter image description here

I need an assistance, thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.