q("update photo set content = '%s' where resource_id = '%s' and uid = %d and imgscale = 0",
q("update photo set content = CASE imgscale WHEN 0 THEN '%s' ELSE CONCAT('%s', '-', imgscale) END where resource_id = '%s' and uid = %d and os_storage = 1",
dbescbin($newstorepath),
dbescbin($newstorepath),
dbesc($resource_id),
intval($channel_id)
);
// now rename the thumbnails in os_storage - the original should have been copied before already
$ps=q("SELECT content, imgscale FROM photo WHERE uid = %d AND resource_id = '%s' and imgscale > 0 and os_storage = 1",