Problem with image loading

Asked

Viewed 92 times

1

That’s the problem that if anyone can help.

inserir a descrição da imagem aqui

Here is the HTML code...

here is the part where will load the image with the product that will be added.

                      <div class="row">
                        <div class="box-all">                               
                            <!--{loop:i}-->
                            <!--{<div class="span2">}-->
                            <!--{  <a href="[baseUri]/produto/i.categoria_url/i.sub_url/i.item_url/i.item_id/">}-->
                            <!--{     <div class="box-item tips-top" title="ver detalhes">}-->
                            <!--{        <div class="box-item-oferta-i.item_oferta"><span class="label label-important">Oferta</span></div>}-->
                            <!--{        <div class="box-item-foto"><img src="thumber.php?q=70&zc=2&w=160&h=160&src=fotos/i.foto_url" width="160" height="160" /></div>}-->
                            <!--{        <div class="box-item-detalhe">}-->
                            <!--{          <h2>i.item_short_title</h2>}-->
                            <!--{          <h4 class="i.showHide">De R$ i.item_valor_original</h4>}-->
                            <!--{          <h3>i.item_preco <br/> <small>i.item_valor_parc</small></h3>}-->
                            <!--{        </div>}-->                            
                            <!--{     </div>}-->
                            <!--{  </a>}-->
                            <!--{</div>}-->
                            <!--{end:i}-->
                        </div>

And here’s the PHP code...

here is where the path of images.

    <?php

class Thumb extends PHPFrodo
{

    public function welcome()
    {
        if ( isset( $this->uri_segment[1] ) )
        {
            $pic = "app/fotos/" . $this->uri_segment[1] . ".jpg";
            if ( !file_exists( $pic ) )
            {
                $pic = "app/fotos/" . $this->uri_segment[1] . ".png";
                if ( !file_exists( $pic ) )
                {
                    $pic = "app/images/default/nopic.jpg";
                }
            }
            $this->helper( 'canvas' );
            $t = new Canvas;
            $t->carrega( $pic );
            $image_x = $this->uri_segment[2];
            $image_y = $this->uri_segment[3];
            if ( isset( $this->uri_segment[4] ) && $this->uri_segment[4] == 'ratio' )
            {
                $t->redimensiona( $image_x, $image_y, 'crop' );
            }
            else
            {
                $t->redimensiona( $image_x, $image_y );
            }
            $t->grava( null, 85 );
        }
    }

    public function slide()
    {
        if ( isset( $this->uri_segment[2] ) )
        {
            $pic = "app/fotos/slide/" . $this->uri_segment[2] . ".jpg";
            if ( !file_exists( $pic ) )
            {
                $pic = "app/fotos/slide/" . $this->uri_segment[2] . ".png";
                if ( !file_exists( $pic ) )
                {
                    $pic = "app/images/default/nopic.jpg";
                }
            }
            $this->helper( 'canvas' );
            $t = new Canvas;
            $t->carrega( $pic );
            if ( isset( $this->uri_segment[3] ) )
            {
                $image_x = $this->uri_segment[3];
                $image_y = $this->uri_segment[4];
                if ( isset( $this->uri_segment[5] ) && $this->uri_segment[5] == 'crop' )
                {
                    $t->redimensiona( $image_x, $image_y, 'crop' );
                }
                else
                {
                    $t->redimensiona( $image_x, $image_y );
                }
            }
            $t->grava( null, 85 );
            //$t->grava();
        }
    }

    public function slider()
    {
        $pic = "app/fotos/slide/" . $this->uri_segment[2] . ".jpg";
        if ( !file_exists( $pic ) )
        {
            $pic = "app/fotos/slide/" . $this->uri_segment[2] . ".png";
            if ( !file_exists( $pic ) )
            {
                $pic = "app/images/default/nopic.jpg";
            }
        }
        $handle = new upload( $pic );
        $handle->image_resize = true;
        if ( isset( $this->uri_segment[5] ) && $this->uri_segment[5] == 'crop' )
        {
            $handle->image_x = $this->uri_segment[3];
            $handle->image_y = $this->uri_segment[4];
            $handle->image_ratio_crop = true;
        }
        elseif ( isset( $this->uri_segment[5] ) && $this->uri_segment[5] == 'ratio' )
        {
            $handle->image_x = $this->uri_segment[3];
            $handle->image_y = $this->uri_segment[4];
            $handle->image_ratio_y = true;
            //$handle->image_ratio_x = true;
        }
        else
        {
            $handle->image_x = $this->uri_segment[3];
            $handle->image_y = $this->uri_segment[4];
        }
        $handle->png_compression = 9;
        $handle->jpeg_quality = 85;
        @header( 'Content-type: ' . $handle->file_src_mime );
        echo $handle->Process();
        die();
    }

    public function thumbr()
    {
        $pic = "app/fotos/" . $this->uri_segment[2] . ".jpg";
        if ( !file_exists( $pic ) )
        {
            $pic = "app/fotos/" . $this->uri_segment[2] . ".png";
            if ( !file_exists( $pic ) )
            {
                $pic = "app/images/default/nopic.jpg";
            }
        }
        $handle = new upload( $pic );
        $handle->image_resize = true;
        if ( isset( $this->uri_segment[5] ) && $this->uri_segment[5] == 'crop' )
        {
            $handle->image_x = $this->uri_segment[3];
            $handle->image_y = $this->uri_segment[4];
            $handle->image_ratio_crop = true;
        }
        elseif ( isset( $this->uri_segment[5] ) && $this->uri_segment[5] == 'ratio' )
        {
            $handle->image_x = $this->uri_segment[3];
            $handle->image_y = $this->uri_segment[4];
            //$handle->image_ratio_y = true;
            $handle->image_ratio_x = true;
        }
        else
        {
            $handle->image_x = $this->uri_segment[3];
            $handle->image_y = $this->uri_segment[4];
        }
        $handle->jpeg_quality = 85;
        @header( 'Content-type: ' . $handle->file_src_mime );
        echo $handle->Process();
        die();
    }

    public function t()
    {
        $pic = "app/fotos/" . $this->uri_segment[2] . ".jpg";
        if ( !file_exists( $pic ) )
        {
            $pic = "app/fotos/" . $this->uri_segment[2] . ".png";
            if ( !file_exists( $pic ) )
            {
                $pic = "app/images/default/nopic.jpg";
            }
        }
        if ( empty( $this->uri_segment[2] ) )
        {
            $pic = "app/images/default/nopic.jpg";
        }
        $handle = new upload( $pic );
        $handle->image_resize = true;
        if ( isset( $this->uri_segment[5] ) && $this->uri_segment[5] == 'crop' )
        {
            $handle->image_x = $this->uri_segment[3];
            $handle->image_y = $this->uri_segment[4];
            $handle->image_ratio_crop = true;
        }
        elseif ( isset( $this->uri_segment[5] ) && $this->uri_segment[5] == 'ratio' )
        {
            $handle->image_x = $this->uri_segment[3];
            $handle->image_y = $this->uri_segment[4];
            //$handle->image_ratio_x = true;
            $handle->image_ratio_y = true;
        }
        else
        {
            $handle->image_x = $this->uri_segment[3];
            $handle->image_y = $this->uri_segment[4];
        }
        $handle->jpeg_quality = 90;
        @header( 'Content-type: ' . $handle->file_src_mime );
        echo $handle->Process();
        die();
    }
}
/*end file*/

Detail Important inside the administrator panel the image usually appears more when entering the site it does not appear and when you click on the product of the above problem...

Here the code where loads the new products added...

    var baseUri = $('base').attr('href').replace('/app/', '');
$(function () {
    //$(window).load(function () {
        //carrega novos produtos (ultimos cadastrados)
        var url = baseUri + '/index/FillMaisNovosVistos/2/';
        $.getJSON(url, function (data) {
            $('#mais-novos .slides').html('');
            $(data).each(function (k, v) {
                var link = ''
                link += '<div class="span2">';
                link += ' <div class="box-item tips-top" title="ver detalhes">';

                link += '   <a href="' + baseUri + '/produto/' + v.categoria_url + '/' + v.sub_url + '/' + v.item_url + '/' + v.item_id + '/">';

                link += '     <div class="box-item-foto">'
                link += '       <img src="' + baseUri + '/app/thumber.php?q=80&zc=2&w=140&h=140&src=fotos/' + v.foto_url + '" style="width:140px !important" width="140" height="140"  class="img-responsive"/>';
                link += '     </div>'

                link += '     <div class="box-item-detalhe">'
                link += '      <h2>' + v.item_short_title + '</h2>'
                                if (v.item_valor_original) {
                                link += '<h4>De R$ ' + v.item_valor_original + '</h4>';
                                }                
                link += '      <h3>' + v.item_preco + '</h3>'
                link += '     </div>'

                link += '</a>'
                link += '</div>';
                link += '</div>';

                $('<li />')
                        .attr('id', v.item_id)
                        .html(link)
                        .appendTo($('#mais-novos .slides'));
            });

1 answer

2


I believe that is why src looks for a path, put all the content requesting the image in a function where the Return is the complete path.

kind of

function linkimg(){

 url = thumber.php?q=70&zc=2&w=160&h=160&src=fotos/i.foto_url;
 return url;

}

something with ajax in order to return a obj or json to facilitate.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.