Skip to content

Commit ed87042

Browse files
committed
add default object incase opts is empty on the picture helper
1 parent 7ecdec8 commit ed87042

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/images/utils/imageStore.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const imageStore = (manifest, plugin) => {
1111
const file = manifest[path];
1212
return getLargest(file.sizes, file.format, maxWidth);
1313
},
14-
picture: function picture(path, opts) {
14+
picture: function picture(path, opts = {}) {
1515
try {
1616
// maxWidth, the largest resolution this should ever display.
1717
const { maxWidth, class: classStr, alt, wrap } = { maxWidth: 2000, class: '', alt: '', ...opts };
@@ -40,7 +40,9 @@ const imageStore = (manifest, plugin) => {
4040
picture += `</picture>`;
4141

4242
let pictureWithWrap = `<div class="${opts.ignoreCssString ? 'custom-ejs' : 'ejs'}" ${
43-
plugin.addStyles && !opts.ignoreCssString ? `style="padding-bottom: ${Math.round((file.height / file.width) * 10000) / 100}%;"` : ''
43+
plugin.addStyles && !opts.ignoreCssString
44+
? `style="padding-bottom: ${Math.round((file.height / file.width) * 10000) / 100}%;"`
45+
: ''
4446
}>`;
4547

4648
if (plugin.config.placeholder) {

0 commit comments

Comments
 (0)