Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
problem-builder
Commits
93846186
Commit
93846186
authored
Mar 11, 2016
by
Omar Khan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix cross-domain images and images with relative urls or without explicit protocol
parent
a4e1e429
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
problem_builder/public/js/dashboard.js
+12
-0
No files found.
problem_builder/public/js/dashboard.js
View file @
93846186
...
@@ -8,6 +8,18 @@ function PBDashboardBlock(runtime, element, initData) {
...
@@ -8,6 +8,18 @@ function PBDashboardBlock(runtime, element, initData) {
var
generateDataUriFromImageURL
=
function
(
imgURL
)
{
var
generateDataUriFromImageURL
=
function
(
imgURL
)
{
// Given the URL to an image, IF the image has already been cached by the browser,
// Given the URL to an image, IF the image has already been cached by the browser,
// returns a data: URI with the contents of the image (image will be converted to PNG)
// returns a data: URI with the contents of the image (image will be converted to PNG)
// Expand relative urls and urls without an explicit protocol into absolute urls
var
a
=
document
.
createElement
(
'a'
);
a
.
href
=
imgURL
;
imgURL
=
a
.
href
;
// If the image is from another domain, just return its URL. We can't
// create a data URL from cross-domain images:
// https://html.spec.whatwg.org/multipage/scripting.html#dom-canvas-todataurl
if
(
a
.
origin
!==
window
.
location
.
origin
)
return
imgURL
;
var
img
=
new
Image
();
var
img
=
new
Image
();
img
.
src
=
imgURL
;
img
.
src
=
imgURL
;
if
(
!
img
.
complete
)
if
(
!
img
.
complete
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment