Conditions | 3 |
Total Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | # frozen_string_literal: true |
||
25 | def convert_image_to_avatar(user) |
||
26 | begin |
||
27 | # Get the last part of the url |
||
28 | name = user.image.split("/").last |
||
29 | |||
30 | file = File.open(user.image) |
||
31 | |||
32 | # Upload file if its an image |
||
33 | user.avatar.attach(io: file, filename: name) if file.content_type.start_with?("image/") |
||
34 | rescue e |
||
35 | logger.error("Support: Image URL is not valid/available - #{user.uid} - #{user.image}") |
||
36 | end |
||
37 | end |
||
38 | |||
43 |