簡體   English   中英

圖像不會在Firefox中加載

[英]Image won't load in firefox

我今天遇到FireFox的問題,

當我想在Chrome上傳圖像(並使用php調整大小)時,它可以正常工作,並在之后顯示圖像。 當我在FireFox上嘗試相同時,它將不會加載圖像。

這是一個帶有加載錯誤的示例圖像:

在此輸入圖像描述

更新

我稱之為ImageProcessor類

$ImageProcessor = new ImageProcessor();
$ImageProcessor->Load("/home/admin/domains/dev050.nl/public_html/web/media/uploads/".$rand.$ext);
$ImageProcessor->Resize(250, 180, RESIZE_STRETCH);
$ImageProcessor->Save("/home/admin/domains/dev050.nl/public_html/web/media/advertorials/".$rand.$ext,100);

功能:

/**
 * Resize
 *
 * @param int $width
 * @param int $height
 * @param define $mode
 * @param bool $auto_orientation houd rekening met orientatie wanneer er een resize gebeurt
 */
public function Resize($width=100, $height=100, $mode=RESIZE_STRETCH, $auto_orientation=false){

    // Validate resize mode
    $valid_modes = array("stretch", "fit", "crop");
    if(in_array($mode, $valid_modes)){
        $this->_resize_mode = $mode;
    }else{
        $this->showError("The resize mode '" . $mode . "' does not exists.");
    }

    // Aspect ratio resize based on width
    if(is_numeric($width) && !is_numeric($height)){
        $ratio = $this->_old_width / $width;
        $height = ceil($this->_old_height / $ratio);
    }

    // Aspect ratio resize based on height
    if(is_numeric($height) && !is_numeric($width)){
        $ratio = $this->_old_height / $height;
        $width = ceil($this->_old_width / $ratio);
    }

    // Mode calculations
    switch($mode){
        case "stretch":
            $dst_x = 0;
            $dst_y = 0;
            $src_x = 0;
            $src_y = 0;
            $dst_w = $width;
            $dst_h = $height;
            $src_w = $this->_old_width;
            $src_h = $this->_old_height;
            break;
        case "fit":
            $dst_x = 0;
            $dst_y = 0;
            $src_x = 0;
            $src_y = 0;
            $dst_w = ($this->_old_width > $this->_old_height) ? $this->_old_width : $width;
            $dst_h = ($this->_old_height > $this->_old_width) ? $this->_old_height : $height;
            $src_w = $this->_old_width;
            $src_h = $this->_old_height;
            if($dst_w == $this->_old_width){
                $ratio = $dst_h/$this->_old_height;
                $dst_w = floor($dst_w * $ratio);
            }
            if($dst_h == $this->_old_height){
                $ratio = $dst_w/$this->_old_width;
                $dst_h = floor($dst_h * $ratio);
            }

            $width = $width > $dst_w ? $dst_w : $width;
            $height = $height > $dst_h ? $dst_h : $height;
            break;
        case "crop":
            $width = $width > $this->_old_width ? $this->_old_width : $width;
            $height = $height > $this->_old_height ? $this->_old_height : $height;
            $dst_x = 0;
            $dst_y = 0;
            $calc_x = ceil($this->_old_width/2) - floor($width / 2);
            $src_x = $calc_x > 0 ? $calc_x : 0;
            $calc_y = ceil($this->_old_height/2) - floor($height / 2);
            $src_y = $calc_y > 0 ? $calc_y : 0;
            $dst_w = $this->_old_width;
            $dst_h = $this->_old_height;
            $src_w = $this->_old_width;
            $src_h = $this->_old_height;
            break;
    }

    // Set news size vars because these are used for the
    // cache name generation
    $this->_new_width = $width;
    $this->_new_height = $height;

    $this->_old_width = $width;
    $this->_old_height = $height;

    // Lazy load for the directurl cache to work
    $this->lazyLoad();
    if($this->_cache_skip) return true;

    // Create canvas for the new image
    $new_image = imagecreatetruecolor($width, $height);

     // Check if this image is PNG or GIF to preserve its transparency
    if(($this->_image_type == 1) || ($this->_image_type == 3))
    {
        imagealphablending($new_image, false);
        imagesavealpha($new_image,true);
        $transparent = imagecolorallocatealpha($new_image, 255, 255, 255, 127);
        imagefilledrectangle($new_image, 0, 0, $width, $height, $transparent);
    }

    imagecopyresampled($new_image, $this->_image_resource, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);

    // Apply transparency to resized gif images
    if($this->_extension == "gif"){
        $trnprt_indx = imagecolortransparent($resource);
        if ($trnprt_indx >= 0) {
            $trnprt_color    = imagecolorsforindex($this->_image_resource, $trnprt_indx);
            $trnprt_indx    = imagecolorallocate($new_image, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
            imagefill($new_image, 0, 0, $trnprt_indx);
            imagecolortransparent($new_image, $trnprt_indx);
        }
    }

    $this->_image_resource = $new_image;
}

嘗試清除緩存,也許它加載但在上下文之下?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM