- dbesc($r[0]['filename']),
- intval($y),
- intval($x),
- dbesc($s));
- if($r === NULL)
- $_SESSION['sysmsg'] .= "Image size reduction (80) failed." . EOL;
- $r = q("UPDATE `profile` SET `photo` = '%s', `thumb` = '%s' WHERE `id` = %d LIMIT 1",
- dbesc($a->get_baseurl() . '/photo/' . $image_id . '-4.jpg'),
- dbesc($a->get_baseurl() . '/photo/' . $image_id . '-5.jpg'),
- intval($profile_id));
- if($r === NULL)
- $_SESSION['sysmsg'] .= "Failed to add image to profile." . EOL;
+ dbesc($base_image['filename']),
+ intval($im->getHeight()),
+ intval($im->getWidth()),
+ dbesc($im->imageString())
+ );
+
+ if($r === false)
+ notice("Image size reduction (80) failed." . EOL);
+
+ // Unset the profile photo flag from any other photos I own
+
+ $r = q("UPDATE `photo` SET `profile` = 0 WHERE `profile` = 1 AND `resource-id` != '%s' AND `uid` = %d",
+ dbesc($base_image['resource-id']),
+ intval($_SESSION['uid'])
+ );