-
Notifications
You must be signed in to change notification settings - Fork 257
Migrated functions using heic2any to heic-convert; Update CSP #8100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
73c4dfc
c146437
bd4c1e6
7886104
39d3eb9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,11 +39,15 @@ export class ImageViewer extends React.PureComponent { | |
| if (["image/heic", "image/heif"].includes(this.props.mime_type)) { | ||
| // Returns a promise containing an object URL for a JPEG image converted from the HEIC/HEIF format. | ||
| return fetch(this.props.url) | ||
| .then(res => res.blob()) | ||
| .then(blob => | ||
| import("heic2any").then(({default: heic2any}) => heic2any({blob, toType: "image/jpeg"})) | ||
| .then(res => res.arrayBuffer()) | ||
| .then(arrayBuffer => new Uint8Array(arrayBuffer)) | ||
| .then(inputBuffer => | ||
| import("heic-convert/browser").then(({default: convert}) => | ||
| convert({buffer: inputBuffer, format: "JPEG", quality: 1}) | ||
| ) | ||
| ) | ||
| .then(conversionResult => URL.createObjectURL(conversionResult)) | ||
| .then(conversionResult => new Blob([conversionResult], {type: "image/jpeg"})) | ||
| .then(blob => URL.createObjectURL(blob)) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this |
||
| .then(JPEGObjectURL => this.setState({url: JPEGObjectURL})); | ||
| } else { | ||
| return new Promise(() => this.setState({url: this.props.url})); | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can delete this line for
script_src(since we can now just use the default set incontent_security_policy.rb). However, you should leave the comment aboutheic-convertcreating images as a blob, which is the reason we still need thep.img_srcline below. (But remove the TODO, I don't think there's a good way we can get around this.)