Skip to content

Commit

Permalink
fix large images
Browse files Browse the repository at this point in the history
  • Loading branch information
timoj committed Nov 15, 2017
1 parent fc440dc commit 3c8aca9
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions includes/wcwuunder-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ private function buildWuunderData($orderId)
$order = new WC_Order($orderId);
$orderPicture = $this->get_base64_image($orderItems['images'][0]);


$defLength = 80;
$defWidth = 50;
$defHeight = 35;
Expand Down Expand Up @@ -324,12 +325,17 @@ public function get_base64_image($picture)
{

$imagepath = $picture;
$imagetype = pathinfo($imagepath, PATHINFO_EXTENSION);
$imagedata = file_get_contents($imagepath);
$image = base64_encode($imagedata);

return $image;

try {
if (filesize($imagepath) <= 2097152) { //smaller or equal to 2MB
$imagedata = file_get_contents($imagepath);
$image = base64_encode($imagedata);
} else {
$image = "";
}
return $image;
}catch(Exception $e) {
return "";
}
}

public function add_listing_actions($order)
Expand Down

0 comments on commit 3c8aca9

Please sign in to comment.