Adding Images or Video to the Handbook
Images
Adding Images to Google Cloud Storage
- View the sourcegraph-assets bucket
- If you don’t have permission to view the contents of this link, ask the team in #it-tech-ops for Google Cloud Storage permissions to add images to the Handbook.
- Make sure your file has a unique name that clearly describes the image or video. There are lots of files in Google Cloud Storage, and you want to be able to identify yours easily.
- Avoid special characters or spaces as they can sometimes interfere with Markdown rendering. For example:
adding-images-screenshot
- Avoid special characters or spaces as they can sometimes interfere with Markdown rendering. For example:
- Navigate to the handbook/ folder found in the link in step 1. You can scroll through the list or search.
- Click “Upload Files” to select your file, and click “Open”.
Adding Images from Google Cloud Storage to the Handbook
-
In Google Cloud Storage, copy the URL for the image you want to include.
- You can do this by clicking the file name to see more details, then copying the “Public URL”.
-
To insert your image into the Handbook, follow this format:
![Alt Text](Image URL)
Alt Text
is a description of your image. Learn more here.Image URL
is the URL you copied in step 1. It will look something like this:https://storage.googleapis.com/sourcegraph-assets/handbook/adding-images-demo.png
-
Finish editing and merge your changes as normal.
Videos
The easiest way to add a video to the Handbook is to embed it. Most video hosting sites, like Youtube or Loom, include an “embed” option in their sharing menu. The link should look something like this:
<div style="position: relative; padding-bottom: 56.25%; height: 0;">
<iframe
src="video URL"
frameborder="0"
webkitallowfullscreen
mozallowfullscreen
allowfullscreen
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"
></iframe>
</div>
Copy and paste that link into your markdown file as you would any other piece of text. Check your handbook page after merging your changes to verify your video is playing correctly.
Uploading Other Large Files
If you want to upload a large file (such as a large image, video, or audio recording) and make it available in the handbook, upload the file to Google Drive and then get a shareable link to the file on Google Drive. Add that link to the handbook. Don’t add large files to the handbook repository itself (because Git is not a good way to store large non-text files).
Should I ever store these types of files in a Handbook directory?
When working with SVGs, you may want to store an image directly in a Handbook directory, rather than in Google Cloud Storage. SVGs are a superior file format for things like diagrams, flowcharts, logos, illustrations that contain text etc because the text is accessible, the image scales and stays super sharp, and the file size is much smaller (faster loading times!). Because they are not binary but text and small in file size, these can be committed directly to the repo. Where possible, using SVGs and adding it directly to the repo is the preferred method. You can see an example here.
Images that are not vector-based, e.g. photos (taken with a camera) or most screenshots, are binary and have larger file sizes. Common file formats are JPG, PNG, GIF. Git cannot store these efficiently and they would increase the repository size a lot. Even if they are deleted later, they will forever remain in the history, so it’s important to never add these to the repo in the first place. So, binary files like JPG and PNG should always be uploaded to sourcegraph-assets on Google Cloud Storage.