Skip navigation
All Places > Instructional Designers > Blog > Author: Mark Garcia

Instructional Designers

3 Posts authored by: Mark Garcia


Previously, I was attempting to help Terry Smith with an issue related to iframe content not rendering properly in Canvas and the Canvas mobile app. To see our initial discourse, checkout Iframe links on mobile app. From these communications, I gathered information related to the issue, and I think that I have devised a solution for it. Before I get too far into it however, I wanted to first details what we are attempting to do here and why we are attempting to do it.


Figure 1. We are attempting to upload a .html file and then embed it into an iframe on a page.


Rather than creating a simply link or anchor tag to the file, we are attempting to embed it in a page of the Canvas course. Why would we want to do this? Well there are a couple of advantages that come with embedding an HTML file including:


Pros to embedding an html document in an iframe

  1. You have control over they layout of all of the elements of the file, giving you a greater level of how they are laid out with regards to one another.
  2. You can add a <style> tag to the <head> of your html document, giving you a wider range of options with regards to how the elements look, feel, and even behave on the page. The styles options that are available via this method are wider than inline styles.
  3. If you are brave enough and knowledgable enough, you can actually write javascript or jQuery code that will enable features that would otherwise only be available on the desktop version of Canvas, but are missing in the mobile app versions.

While this may seem like a favorable option, before we begin, I must point out that there can be some unforeseen complications that arise when attempting to put any content into an iframe.


Cons & Complications to embedding an html document in an iframe

  1. Any content that originates from a url that begins with http instead of https will not be allowed to render in your Canvas course. This is a security protection measure.
  2. While the iframe will render the content, depending upon the width of the origin page, the content may render in a way that requires vertical scrolling, horizontal scrolling, or both.
  3. If you don't have access to the origin file (.html) for the iframe, then any links clicked in the iframe will lead to their designated pages, but those pages will render in the iframe itself. This can lead to some very weird/unexpected/non-ideal renderings of pages, from your Canvas course or otherwise, in the iframe itself. 
  4. If the file referenced in the iframe originates from your Canvas course, it will render in a weird sort of way (see item 3) unless you acquire the path to it correctly.



I have created a simple solution to demonstrate the possibilities when the four complications are addressed appropriately. If you are more comfortable with HTML and CSS, then feel to take the information here and run with it to your heart's content. If you aren't so familiar with HTML and CSS, never fear. I will provide you with all of the materials so that you can at least play around with this and maybe learn a thing or two.


Video Tutorial

If you would like to watch a video of me talking through this, it is directly below. If you instead prefer to follow along on the page, then simply skip the video for now.



Step-by-step Tutorial


What We Will Need

  1. A .html document. If you would like to borrow one from me, you can find it here.
  2. A text editor so that you can open the .html document and modify the code. I prefer Sublime, but choose the one that you are comfortable with.
  3. A new page in a Canvas to which we will add the iframe.
  4. A basic understanding of the HTML editor in Canvas. If you have embedded YouTube iframes using it, then you are good.
  5. A little bit of free time and patience.


Getting the .html File Ready for Upload

Before we upload it, there are a couple of things that we want to make sure of when it comes to our .html file. I have detailed them below:

  1. Open the .html file in your text editor.
  2. Make sure that you have added urls for the anchor tags <a> in either your .html file or the one that I provided you with. If you need to know where to put the url, locate the three anchor tags that I have added on lines 134-136 and paste you links over where it reads yourLinkGoesHere. Make sure your link is between the two quotes.
    <a class="button is-1" href="yourLinkGoesHere">Go to Page</a>
    <a class="button is-2" href="yourLinkGoesHere">Go to Syllabus</a>
    <a class="button is-3" href="yourLinkGoesHere">Go to Modules</a>
  3. Locate the closing head tag in your .html file. If you are using my example, it should be around line 131, and it will look like this:
  4. Place your cursor right before the < of the </head> tag and hit return/enter to add a blank line. In that blank line, add the following code:
    <base target="_parent">
    Note: if the code is already there, you may skip step 4.
  5. Go to the Files section of your Canvas course and upload the .html file.


Before we proceed, I want to talk about the importance of step 4. When we go to embed our .html document into our Canvas page, what we will really be doing is placing our document inside of an <iframe> element which is, itself, inside of another .html document. Essentially we are performing the Inception of web design. Essentially, when the page is fully loaded the code is going to look something like this:

<!DOCTYPE html>
          <!-- Canvas' HEAD content -->
          <!-- Canvas' BODY content, including our ... -->
                    <!DOCTYPE html> <!-- this is actually the start of our .html file -->
                              <!-- The HEAD content from our .html file -->
                              <!-- The BODY content, including the buttons, from our .html -->


Why does this matter?

Well, the problem that can arise is that if the iframe is rendering a separate html document from the Canvas one that the browser you are using is rendering, then any links that exist, and are clicked, within the iframe html document will only open new tabs and windows within the iframe's document. To correct this behavior, we introduce the <base> parameter in the head. This sets a base behavior for all clicked links originating from our .html file. The target="_parent" piece of the base code essentially says, "when a link is clicked, the base behavior is to open that link  in the parent window." Had we not done this, we would expect to have aberrant behavior on link clicks, where windows would load inside of windows, and you would most likely get something that looks like this:


Figure 2. When a page in your Canvas course becomes Inception. 


Notice how both the global nav and the course nav are still rendered in my iframe. That is not the behavior that I want, and this is the behavior that the <base> parameter corrects.


Creating the <iframe>

  1. First, we need to get the link to our .html file, so click on Files in the Canvas course menu.
  2. Locate the .html file and click on it. This should open up a preview window.
  3. Make sure the developer console is enabled in your browser, right click on any are of the preview window where your file is currently rendered and choose Inspect Element from the list of options. Use my Verifying Mobile Friendly Web Content tutorial if you have forgotten how to access the developer console.
  4. In the source code that appears, you should be able to locate an <iframe> that has the following parameters:
    <iframe allowfullscreen="" title="File Preview" src="/courses/######/files/########/file_preview?annotate=0" class="ef-file-preview-frame ef-file-preview-frame-html" data-reactid="."></iframe>
    Where the #'s  in the src="" parameter will represent your unique course id number and the unique number associated with the file. Copy the src="" parameter.
  5. Modify the src="" parameter that you just copied so that it looks like this:
    Where INSTITUTION is replaced with your specific institution's name for your Canvas instance, and again, the #'s are replaced with the distinct course and file ID's.
  6. Copy the src parameter that you have created. We will be using it soon.
  7. Create a new page in your Canvas course, and, switch from the Rich Content Editor to the HTML Editor by tapping the link in the upper right.
  8. Create an iframe, and include the src parameter you saved, so that it looks like this:
    <iframe src="">
    We will now add a few things to the iframe so that it will behave a little nicer when we save it.
  9. Just before the src= parameter add style="width: 100%; height: 300px; overflow hidden" so that you iframe now looks like this:
    <iframe style="width: 100%; height: 300px; overflow: hidden" src="">
    By setting the width to 100%, the iframe will behave in a responsive manner, always growing or shrinking to fill whatever space is actually allotted to it. You may need to experiment with the height, depending upon how tall your container will be. If you have a lot of buttons and text, you will need to increase the height parameter until everything is visible (you will see the cutoff if you didn't make your iframe tall enough). The overflow parameter is a personal preference on my part. I choose to make my iframes tall enough so that all of their content is visible with needing to scroll within them. If you don't set your overflow, you may find that you, or your students, have to scroll either horizontally or vertically within the iframe to see all of its content. This will involve scrolling ON TOP of the scrolling that is already happening in the main window as a result of Canvas' html.
  10. Finally, modify the iframe by adding scrolling="no" just before the > of the opening <iframe> tag. Your finalized code should look something like this:
    <iframe style="width: 100%; height: 300px; overflow: hidden" src="" scrolling="no">
    This scrolling parameter is a fallback for the overflow style that we added in step 9, and ensures that there is no scrolling allowed in the iframe. Again, this is a personal preference, but you are welcome to not utilize this if you feel it is unnecessary.
  11. Save the page.
  12. You should be good to go! Check your page on both the desktop and mobile versions of Canvas, and click all of your links to ensure that they are opened in the main browser window.



As you can see, this opens the door for instructional designers and instructors to build out content that is not based solely on inline css styles or the stylesheets provided by Instructure. I am excited to see what you all choose to do with this information, and as always, please feel free to contact me if you have questions or concerns about getting this up and running.

A New Perspective

You no doubt have probably been on Google maps or Facebook, or another website, and found an interactive image, that allows you to look around in 360°. While exploring the content you may have even had the thought,

Well this is all well and good for the tech giants, but what about me? I could use this type of content for so much! I could go to a local art gallery and share the experience with my students! Perhaps I could travel to a foreign country and snap 360° photos for my students and have them explore along with me when their Canvas course starts. Maybe I could go into a science laboratory or out in the field and snap photos of the space so that they could get a better notion of what is involved in my profession.

Well, fear not ambitious innovator, I am here to show you how you could easily embed content such as this in your Canvas course so that your students can get an experience like this! While the process may seem somewhat daunting initially, if you have the free right tools you should be able to get this up and running in no time at all... I should mention that in this rare instance, the right tools and the free tools are one and the same!


Check out the demo below first, and if you like what you see, read on to learn how to make one of your own!



Check out the demo of what we are going to make in this tutorial!


What You Will Need

Some of these items are items that you will need to download, while others you will just need to be aware of for now.

  1. Google Street View App (Free Download for iOS or Android).
  2. An image editing tool that will allow us to resize the photo (covered below for each OS).
  3. An Imgur account. Sign up for free or Login if you have an existing account.
  4. Check out the Javascript library that we will be using, Pannellum. Specifically click on Documentation > Examples. Don't worry too much about this right now, as I will explain how we are going to use it in just a moment.


Once you have/are aware of these three things, you are ready to begin.


Creating a 360° Image with Street View

There is some initial set up that we will need to do with the Street View App before we are ready to get out there and start taking photos.



  1. Make sure you have logged in to a Google account, or create a new one.
  2. Tap on the menu icon  in the upper left corner of the app and navigate to Settings. Once there verify that you have enabled/setup the option to Save the photo to an album on your phone (this option may be a little different between iOS and Android).


Taking Your 360° Photo 

Your setup complete, you are now ready to take your 360° photo. This is a fairly easy endeavor. Simply:

  1. Find a venue (try a venue with a lot of space. The larger the space, the easier it will be to get cleaner stitching on the photo).
  2. Tap on the Camera icon in the lower right.
  3. Select Camera from the options that are you are given.
  4. A view finder menu will appear with instructions. Follow the instructions to take the first, and then subsequent photos for your 360° image.
    Figure 1. Aligning the camera with the dot will start the 360° image capture process in the app.
  5. Once you have completed taking all of the photos, the app will "stitch" them together into a 360° photo, and the photo will be saved into an album on your phone. Locate the photo on your phone and get it to your computer so that we can resize it.


Modifying the Photo for Mobile Device Compatability

Resizing Your Photo

Now that we have the photo, we need to resize it so that it will render properly on mobile devices. Specifically, if the largest dimension of the image is > 4096 pixels, we need to shrink it to 4096 pixels while maintaining the aspect ratio.


Find the operating system you are using below, and follow the steps in the linked tutorial to resize the image appropriately.




  1. Right click on your image and choose Open with > Paint to open it in Microsoft Paint.
  2. Once opened, click on the Resize button in the "Image" panel of the ribbon.

    Figure 2. The Resize option in Paint will allow you alter the image's dimensions (Windows).
  3. When the resize window appears, make sure that the box next to Maintain Aspect Ratio is checked.
  4. Click the radio button next to Pixels to select it.
  5. Resize the image so that the widest dimension (usually width) is no greater than 4096 pixels. I typically just set the width to 4096 pixels.
  6. Save the image.



  1. If Preview is not set as your default image viewing application, right click on the image and choose Open with > Preview.
  2. Once in Preview, go to the menu bar at the top of your Mac and click on Tools > Adjust Size.
  3. Make sure that the box next to Scale proportionally is checked.

    Figure 3. The Adjust size option in Preview will allow you alter the image's dimensions (Mac).
  4. Resize the image so that the widest dimension (usually width) is no greater than 4096 pixels. I typically just set the width to 4096 pixels.
  5. Save the image.


Uploading the Photo to imgur

  1. Log in to Imgur.
  2. Click on New Post in the upper left corner and choose Upload Images from the dropdown menu that appears.
  3. Click the Browse button and locate your image, or drag and drop the image into the window that appears to begin the upload.
  4. In the page that opens (when the upload begins) click on Post privacy in the lower right, and ensure that you are happy with the privacy setting that is selected. I typically leave images like this set to Private.
  5. Wait until your photo has BOTH uploaded and been processed. Once it has hover on your username in the upper right corner of imgur and click on the images option in the dropdown menu that appears.
  6. Locate your image in the collection that appears, and click on it.
  7. In the window that pops up you should see the image and a plethora of links next to it. Click on Copy next to the Direct Link option.

    Figure 4. The Direct Link option in imgur is what we will use to render our image in Pannellum.
  8. This link is the one that we will use with the final piece of this puzzle. For now, if you need to, paste the link somewhere (word doc, Canavs Page, text file, etc), or just leave this window of imgur open, and we can come back to it later.
  9. Note: We will need to slightly modify this link when we go to use it or Pannellum will not work properly. All that you need to do is convert the direct url from to 


Using Pannellum & Embedding in Canvas Content

We will be using a javascript plugin called Pannellum to help us achieve our embeddable 360° photo, and this photo will, at its most basic level, allow the student to look around and zoom in or out. However, we will be using this tool in its most basic instance. If you are more of an adventurous, or a skilled user of javascript, you can use this tool to build out even more robust widgets that allow the user to interact with pieces of the environment, see an area from multiple points of view, or, you can even create 360° videos! If you would like to see an example of how versatile this tool can be, check out the Pannellum page or you can look at an example that I have built, using their documentation, here.


  1. Copy the following code:

    <p style="border: 1px solid #d7d7d7; position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;">
        <iframe src="" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none;" width="420" height="315" allowfullscreen="allowfullscreen">
  2. Create a new page/assignment/quiz/content in Canvas so that you have your Rich Content Editor open.
  3. Click on HTML Editor in the upper left of the RCE so that you can embed the code that you copied in step 1.
  4. Paste the copied code from step 1 into the HTML Editor, and then locate the Direct link for the imgur image that you copied in step 7 of the imgur instructions. Copy the direct link url.
  5. In the <iframe> src parameter (line 2 of code above), you will notice that there is a string ?panorama=YOURIMGURURL. Highlight YOURIMGURURL and paste over it with the Direct Link url. Remember that your Direct Link url must begin with https NOT http, or it won't work. If it currently is http, just add the 's' onto it.
  6. The <iframe> src parameter should now look something like this: src="" with the only difference between your src parameter and mine being the unique ID (in bold) that signifies your image versus that of mine.
  7. Click Save in the content editor and you now see the iframe rendered as it would be for your students.
  8. Click on the prompt that tells you to Click to Load Panorama and Pannellum should load your image.
  9. Feel free to click and drag in the window to see what it does, and how it works!


Final Thoughts

One addition cool thing about all of this? The iframe maintains functionality in the Canvas mobile app as well!


Figure 5. The <iframe> element retains its functionality even in the Canvas mobile app!

If you or your institution is really looking to build on this, there are a few options that will make the 360° images even better. For one, taking photos with your phone and having them "stitched" together often results in artifacts (ceiling tiles don't line up, breaks in furniture, etc). I would recommend looking into cameras that are built to take 360° pictures and videos, which can range from a ~$200 - $5000. Additionally, you may want to look into the Google Street View website to see what their cameras look like, and to see if you would want to borrow one of them (proposal required).


Additional tip: If you are wanting to use the more robust version of Pannellum in your Canvas courses, it is going to require you to have a secure web server/site where you actually host all of the Pannellum content yourself. Otherwise, Canvas will not render the iframe as it will identify the content as suspicious.

The Challenge

Canvas does a pretty good job of handling responsive design via the Rich Content Editor, but, if there is one thing that I have found I am not the biggest fan of, it is the video thumbnails. Dropping a video into a course and having it simply represented by a small thumbnail just bothers me. I know that I can just link to a YouTube video as an External Tool in a module as well, but I want to include buttons, links, and text in the pages to accompany my videos.


Additionally, simply copying the embed code of a YouTube video gives you set dimensions for the iframe that you drop into your page. The end result is a video container that is either too narrow or too wide depending on the device that you choose to use. Furthermore, while I could have easily set the width of the video container to 100%, making it fluidly adjust to the width of the page, the iframe's height would remain he same, which would give me black, spacing bars on either side of the video.


What I really wanted was to be able to embed my YouTube videos on a page so that I could also enable custom thumbnails for the videos and maintain their aspect ratio no matter the device that was used to view them.



While javascript is an obvious choice for resizing elements, the solution for this issue was actually much easier than I realized. I found the following gist by GitHub user jaicab which detailed a pure CSS method for handling this. Recognizing that I didn't have access to the global CSS for my organization's instance of Canvas, I instead chose to utilize his CSS inline with the paragraph element in Canvas, and the iframe element that is generated for the purposes of embedding YouTube videos. The resulting code for the video looks like this:

<p style="border: 1px solid #d7d7d7; position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;">
<iframe style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none" src="" width="420" height="315" allowfullscreen="allowfullscreen"></iframe>


You can view and resize the container itself on my jsfiddle account here. Another reason that I like to use the embeddable iframe element is that it also allows me to utilize additional video parameters that YouTube has available including video start/end times, modest branding, and autoplay.


If you would like to test it out using any other YouTube video, simply replace my iframe src parameter with the src parameter from the embed code of your video of choice!

Filter Blog

By date: By tag: