Skip to content

Commit 2ba7dae

Browse files
authored
Add a render image hook (#39768)
Images are now lazyloaded, they have width and height attributes and the classes are centralized. Only applies to Markdown images
1 parent 24cc552 commit 2ba7dae

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

site/content/docs/5.3/getting-started/parcel.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ With dependencies installed and our project folder ready for us to start coding,
111111
npm start
112112
```
113113

114-
<img class="img-fluid" src="/docs/{{< param docs_version >}}/assets/img/guides/parcel-dev-server.png" alt="Parcel dev server running">
114+
![Parcel dev server running](/assets/img/guides/parcel-dev-server.png)
115115

116116
In the next and final section to this guide, we'll import all of Bootstrap's CSS and JavaScript.
117117

@@ -150,7 +150,7 @@ Importing Bootstrap into Parcel requires two imports, one into our `styles.scss`
150150

151151
3. **And you're done! 🎉** With Bootstrap's source Sass and JS fully loaded, your local development server should now look like this:
152152

153-
<img class="img-fluid" src="/docs/{{< param docs_version >}}/assets/img/guides/parcel-dev-server-bootstrap.png" alt="Parcel dev server running with Bootstrap">
153+
![Parcel dev server running with Bootstrap](/assets/img/guides/parcel-dev-server-bootstrap.png)
154154

155155
Now you can start adding any Bootstrap components you want to use. Be sure to [check out the complete Parcel example project](https://github.com/twbs/examples/tree/main/parcel) for how to include additional custom Sass and optimize your build by importing only the parts of Bootstrap's CSS and JS that you need.
156156

site/content/docs/5.3/getting-started/vite.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ With dependencies installed and our project folder ready for us to start coding,
135135
npm start
136136
```
137137

138-
<img class="img-fluid" src="/docs/{{< param docs_version >}}/assets/img/guides/vite-dev-server.png" alt="Vite dev server running">
138+
![Vite dev server running](/assets/img/guides/vite-dev-server.png)
139139

140140
In the next and final section to this guide, we’ll import all of Bootstrap’s CSS and JavaScript.
141141

@@ -175,7 +175,7 @@ In the next and final section to this guide, we’ll import all of Bootstrap’s
175175

176176
3. **And you're done! 🎉** With Bootstrap's source Sass and JS fully loaded, your local development server should now look like this:
177177

178-
<img class="img-fluid" src="/docs/{{< param docs_version >}}/assets/img/guides/vite-dev-server-bootstrap.png" alt="Vite dev server running with Bootstrap">
178+
![Vite dev server running with Bootstrap](/assets/img/guides/vite-dev-server-bootstrap.png)
179179

180180
Now you can start adding any Bootstrap components you want to use. Be sure to [check out the complete Vite example project](https://github.com/twbs/examples/tree/main/vite) for how to include additional custom Sass and optimize your build by importing only the parts of Bootstrap's CSS and JS that you need.
181181

site/content/docs/5.3/getting-started/webpack.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ With dependencies installed and our project folder ready for us to start coding,
141141
npm start
142142
```
143143

144-
<img class="img-fluid" src="/docs/{{< param docs_version >}}/assets/img/guides/webpack-dev-server.png" alt="Webpack dev server running">
144+
![Webpack dev server running](/assets/img/guides/webpack-dev-server.png)
145145

146146
In the next and final section to this guide, we'll set up the Webpack loaders and import all of Bootstrap's CSS and JavaScript.
147147

@@ -244,7 +244,7 @@ Importing Bootstrap into Webpack requires the loaders we installed in the first
244244

245245
4. **And you're done! 🎉** With Bootstrap's source Sass and JS fully loaded, your local development server should now look like this:
246246

247-
<img class="img-fluid" src="/docs/{{< param docs_version >}}/assets/img/guides/webpack-dev-server-bootstrap.png" alt="Webpack dev server running with Bootstrap">
247+
![Webpack dev server running with Bootstrap](/assets/img/guides/webpack-dev-server-bootstrap.png)
248248

249249
Now you can start adding any Bootstrap components you want to use. Be sure to [check out the complete Webpack example project](https://github.com/twbs/examples/tree/main/webpack) for how to include additional custom Sass and optimize your build by importing only the parts of Bootstrap's CSS and JS that you need.
250250

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{- $originalSrc := .Destination | safeURL -}}
2+
{{- $localImgPath := path.Join "/site/static/docs" site.Params.docs_version $originalSrc -}}
3+
{{- /* This shouldn't be needed but we have a weird folder structure with version included... */ -}}
4+
{{- $src := urls.JoinPath "/docs" site.Params.docs_version $originalSrc -}}
5+
{{- $config := imageConfig $localImgPath -}}
6+
{{- $classes := "d-block img-fluid" -}}
7+
8+
<img src="{{ $src }}" class="{{ $classes }}" alt="{{ .Text }}" width="{{ $config.Width }}" height="{{ $config.Height }}" loading="lazy">

0 commit comments

Comments
 (0)