Skip to content

Commit a977b25

Browse files
committed
feat(media): work in progress page
1 parent 681434d commit a977b25

File tree

3 files changed

+225
-1
lines changed

3 files changed

+225
-1
lines changed

images/south_cloisters.jpg

118 KB
Loading

pages/media.qmd

Lines changed: 225 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,227 @@
11
---
2-
title: (5) Images, videos and documents
2+
title: Images, videos and documents
33
---
4+
5+
## Images
6+
7+
You can add images to a Quarto page using Markdown.
8+
The basic pattern is:
9+
10+
```markdown
11+
![](image.jpg)
12+
```
13+
14+
In this example, we have an image file called `south_cloisters.jpg` in the `images` folder. The path to the file is:
15+
16+
* `..` meaning "go up one folder".
17+
* `images` is the folder name.
18+
* `south_cloisters.jpg` is the file name.
19+
20+
If your image is in the same folder as your `.qmd` file, you could just write the file name.
21+
22+
This shows the image at its default size and alignment:
23+
24+
```markdown
25+
![](../images/south_cloisters.jpg)
26+
```
27+
28+
![](../images/south_cloisters.jpg)
29+
30+
You can control the size of the image with `width`:
31+
32+
TODO: EXPLAIN CURLY BRACES
33+
34+
```markdown
35+
![](../images/south_cloisters.jpg){width=50%}
36+
```
37+
38+
![](../images/south_cloisters.jpg){width=50%}
39+
40+
To add a caption, put text inside the square brackets:
41+
42+
```markdown
43+
![Photograph of South Cloisters on St Lukes Campus](../images/south_cloisters.jpg)
44+
```
45+
46+
![Photograph of South Cloisters on St Lukes Campus](../images/south_cloisters.jpg)
47+
48+
We can control alignment using `fig-align`:
49+
50+
```markdown
51+
![](../images/south_cloisters.jpg){fig-align="center"}
52+
```
53+
54+
![](../images/south_cloisters.jpg){fig-align="center"}
55+
56+
Adding `.lightbox` lets people click to see a larger version of the image - helpful when you have detailed figures or diagrams.
57+
58+
```markdown
59+
![](../images/south_cloisters.jpg){.lightbox}
60+
```
61+
62+
![](../images/south_cloisters.jpg){.lightbox}
63+
64+
You can also make your figure a hyperlink:
65+
66+
```markdown
67+
[![](../images/south_cloisters.jpg)](https://medicine.exeter.ac.uk/research/facilities/southcloisters/)
68+
```
69+
70+
[![](../images/south_cloisters.jpg)](https://medicine.exeter.ac.uk/research/facilities/southcloisters/)
71+
72+
To add alternative text to your image:
73+
74+
```markdown
75+
![](../images/south_cloisters.jpg){fig-alt="Photograph of South Cloisters on St Lukes Campus"}
76+
```
77+
78+
![](../images/south_cloisters.jpg){fig-alt="Photograph of South Cloisters on St Lukes Campus"}
79+
80+
::: {.pale-blue}
81+
82+
**Task**: Open `media.qmd`, see image is provided in images folder
83+
84+
* [ ] Add image at full width
85+
* [ ] Add it again, 40% width, aligned to right
86+
* [ ] Add third copy with short caption and alt text.
87+
88+
Render the page and compare how the three images look.
89+
90+
:::
91+
92+
## Videos
93+
94+
You can embed videos (for example, from YouTube) using the `video` shortcode. It will show a video player inside your page. Here is an example:
95+
96+
TODO: EXPLAIN WHAT A SHORTCODE IS
97+
98+
```{.markdown shortcodes="false"}
99+
{{< video https://youtu.be/BUN0sSa2e9c?si=-o7gu4FGOZS7L2rt >}}
100+
```
101+
102+
{{< video https://youtu.be/BUN0sSa2e9c?si=-o7gu4FGOZS7L2rt >}}
103+
104+
::: {.pale-blue}
105+
106+
**Task**: On `media.qmd`:
107+
108+
* [ ] Add a YouTube video to the page - for example:
109+
110+
```{.markdown shortcodes="false"}
111+
{{< video https://www.youtube.com/watch?v=dQw4w9WgXcQ >}}
112+
```
113+
114+
Render the page and check that the video player appears.
115+
116+
:::
117+
118+
## Embed websites
119+
120+
Sometimes you might want to show another website (e.g., news article, uni web page, etc.) inside your page. You can do this using an HTML `<iframe>`.
121+
122+
TODO: beginner friendly explanation of HTML syntax and of iframes
123+
124+
```markdown
125+
<iframe width="100%" height="500" src="https://quarto.org/" title="Quarto Documentation"></iframe>
126+
```
127+
128+
<iframe width="100%" height="500" src="https://quarto.org/" title="Quarto Documentation"></iframe>
129+
130+
::: {.pale-blue}
131+
132+
**Task**: On `media.qmd`:
133+
134+
* [ ] Embed a website of your choice using an `<iframe>`.
135+
* [ ] Change the `height` to a different value (e.g., `200`) and see how it changes the space used on the page.
136+
137+
:::
138+
139+
::: {.callout-note title="Advanced Extra: Wrapper" collapse="true"}
140+
141+
Sometimes you may want a header above the iframe.... distinguish embedded page from yours... give it more formal... e.g., open in new tab etc... here is an example wrapper adapted from https://github.com/andrewheiss/ath-quarto/blob/main/cv/index.qmd
142+
143+
````markdown
144+
```{=html}
145+
<div class="iframe-wrapper">
146+
<div class="iframe-header">
147+
<span>Website preview:</span>
148+
<a href="https://quarto.org/"
149+
target="_blank" rel="noopener">
150+
View website in new tab
151+
</a>
152+
</div>
153+
154+
<iframe
155+
width="100%"
156+
height="500"
157+
src="https://quarto.org/"
158+
title="Quarto Documentation">
159+
</iframe>
160+
</div>
161+
<br>
162+
163+
.embed-container {
164+
position: relative;
165+
padding-bottom: 129%;
166+
height: 0;
167+
overflow: hidden;
168+
max-width: 100%;
169+
}
170+
.embed-container iframe,
171+
.embed-container object,
172+
.embed-container embed {
173+
position: absolute;
174+
top: 0;
175+
left: 0;
176+
width: 100%;
177+
height: 100%;
178+
}
179+
```
180+
````
181+
182+
:::
183+
184+
## PDFs
185+
186+
You can embed a PDF so that it appears inside the page. The simplest way (using raw HTML) is:
187+
188+
```markdown
189+
<embed src="media/example.pdf" width="100%" height="1000px" />
190+
```
191+
192+
```{=html}
193+
<embed src="media/example.pdf" width="100%" height="1000px" />
194+
```
195+
196+
::: {.callout-note title="Advanced Extra: Responsive Container" collapse="true"}
197+
198+
If you want more control (for example, a responsive container), you can use CSS:
199+
200+
```
201+
.embed-container {
202+
position: relative;
203+
padding-bottom: 129%;
204+
height: 0;
205+
overflow: hidden;
206+
max-width: 100%;
207+
}
208+
.embed-container iframe,
209+
.embed-container object,
210+
.embed-container embed {
211+
position: absolute;
212+
top: 0;
213+
left: 0;
214+
width: 100%;
215+
height: 100%;
216+
}
217+
```
218+
219+
:::
220+
221+
::: {.pale-blue}
222+
223+
**Task**: we have provided a pdf namem ... on `media.qmd`:
224+
225+
* [ ] Embed the example PDF.
226+
227+
:::

pages/media/example.pdf

131 KB
Binary file not shown.

0 commit comments

Comments
 (0)