ace-helpers 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +23 -11
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -154,7 +154,10 @@ class Helpers {
154
154
  }
155
155
 
156
156
  if (/(video)/.test(thumbnail.type)) {
157
- return `${this.config.assistUrl}/${this.config.slug}/transform/${settingsString}/${thumbnail.name}/thumb.jpg${query}`;
157
+ // `poster` is a frame picked in the CMS (fokus-assist file/thumbnail)
158
+ return `${this.config.assistUrl}/${this.config.slug}/transform/${settingsString}/${thumbnail.name}/${
159
+ thumbnail.poster ? thumbnail.poster.fileName : 'thumb.jpg'
160
+ }${query}`;
158
161
  }
159
162
 
160
163
  if (/(oembed|proxy)/.test(thumbnail.type)) {
@@ -210,9 +213,13 @@ class Helpers {
210
213
  thumbnailSrcset(
211
214
  thumbnail,
212
215
  sizes,
213
- targetWidth = -1,
214
- cropSlug = undefined,
215
- cropFallback = undefined
216
+ {
217
+ targetWidth = undefined,
218
+ noCache = undefined,
219
+ noRedirect = undefined,
220
+ cropSlug = undefined,
221
+ cropFallback = undefined,
222
+ } = {}
216
223
  ) {
217
224
  if (typeof targetWidth === 'string') {
218
225
  const targetWidthPercentage = parseInt(targetWidth, 10) / 100;
@@ -229,7 +236,7 @@ class Helpers {
229
236
  }
230
237
  }
231
238
 
232
- if (typeof targetWidth === 'number' && targetWidth > -1) {
239
+ if (typeof targetWidth === 'number') {
233
240
  const widths = sizes
234
241
  .map((size) => parseInt(Object.keys(size)[0], 10))
235
242
  .sort((a, b) => (a > b ? 1 : -1));
@@ -240,18 +247,23 @@ class Helpers {
240
247
  (size) => parseInt(Object.keys(size)[0], 10) === width
241
248
  );
242
249
 
243
- return this.thumbnailSrc(thumbnail, Object.values(size)[0]);
250
+ return this.thumbnailSrc(thumbnail, Object.values(size)[0], {
251
+ noCache,
252
+ noRedirect,
253
+ cropSlug,
254
+ cropFallback,
255
+ });
244
256
  }
245
257
 
246
258
  return sizes
247
259
  .map(
248
260
  (size) =>
249
- `${this.thumbnailSrc(
250
- thumbnail,
251
- Object.values(size)[0],
261
+ `${this.thumbnailSrc(thumbnail, Object.values(size)[0], {
262
+ noCache,
263
+ noRedirect,
252
264
  cropSlug,
253
- cropFallback
254
- )} ${Object.keys(size)[0]}w`
265
+ cropFallback,
266
+ })} ${Object.keys(size)[0]}w`
255
267
  )
256
268
  .join(', ');
257
269
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ace-helpers",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "Helper module for ACE projects",
5
5
  "main": "index.js",
6
6
  "scripts": {