@@ 25-46 (lines=22) @@ | ||
22 | // get the images and save their file handlers into an array |
|
23 | // so we can do clean up if one fails. |
|
24 | $files = array(); |
|
25 | foreach ($icon_sizes as $name => $size_info) { |
|
26 | $resized = get_resized_image_from_uploaded_file('avatar', $size_info['w'], $size_info['h'], $size_info['square'], $size_info['upscale']); |
|
27 | ||
28 | if ($resized) { |
|
29 | //@todo Make these actual entities. See exts #348. |
|
30 | $file = new ElggFile(); |
|
31 | $file->owner_guid = $guid; |
|
32 | $file->setFilename("profile/{$guid}{$name}.jpg"); |
|
33 | $file->open('write'); |
|
34 | $file->write($resized); |
|
35 | $file->close(); |
|
36 | $files[] = $file; |
|
37 | } else { |
|
38 | // cleanup on fail |
|
39 | foreach ($files as $file) { |
|
40 | $file->delete(); |
|
41 | } |
|
42 | ||
43 | register_error(elgg_echo('avatar:resize:fail')); |
|
44 | forward(REFERER); |
|
45 | } |
|
46 | } |
|
47 | ||
48 | // reset crop coordinates |
|
49 | $owner->x1 = 0; |
@@ 25-46 (lines=22) @@ | ||
22 | // get the images and save their file handlers into an array |
|
23 | // so we can do clean up if one fails. |
|
24 | $files = array(); |
|
25 | foreach ($icon_sizes as $name => $size_info) { |
|
26 | $resized = get_resized_image_from_uploaded_file('avatar', $size_info['w'], $size_info['h'], $size_info['square'], $size_info['upscale']); |
|
27 | ||
28 | if ($resized) { |
|
29 | //@todo Make these actual entities. See exts #348. |
|
30 | $file = new ElggFile(); |
|
31 | $file->owner_guid = $guid; |
|
32 | $file->setFilename("profile/{$guid}{$name}.jpg"); |
|
33 | $file->open('write'); |
|
34 | $file->write($resized); |
|
35 | $file->close(); |
|
36 | $files[] = $file; |
|
37 | } else { |
|
38 | // cleanup on fail |
|
39 | foreach ($files as $file) { |
|
40 | $file->delete(); |
|
41 | } |
|
42 | ||
43 | register_error(elgg_echo('avatar:resize:fail')); |
|
44 | forward(REFERER); |
|
45 | } |
|
46 | } |
|
47 | ||
48 | // reset crop coordinates |
|
49 | $owner->x1 = 0; |
@@ 30-51 (lines=22) @@ | ||
27 | // get the images and save their file handlers into an array |
|
28 | // so we can do clean up if one fails. |
|
29 | $files = array(); |
|
30 | foreach ($icon_sizes as $name => $size_info) { |
|
31 | $resized = get_resized_image_from_uploaded_file('avatar', $size_info['w'], $size_info['h'], $size_info['square'], $size_info['upscale']); |
|
32 | ||
33 | if ($resized) { |
|
34 | //@todo Make these actual entities. See exts #348. |
|
35 | $file = new ElggFile(); |
|
36 | $file->owner_guid = $guid; |
|
37 | $file->setFilename("profile/{$guid}{$name}.jpg"); |
|
38 | $file->open('write'); |
|
39 | $file->write($resized); |
|
40 | $file->close(); |
|
41 | $files[] = $file; |
|
42 | } else { |
|
43 | // cleanup on fail |
|
44 | foreach ($files as $file) { |
|
45 | $file->delete(); |
|
46 | } |
|
47 | ||
48 | register_error(elgg_echo('avatar:resize:fail')); |
|
49 | forward(REFERER); |
|
50 | } |
|
51 | } |
|
52 | ||
53 | // Prepare for GraphQL mutation to PaaS |
|
54 |