Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/js/poster-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class PosterImage extends ClickableComponent {
constructor(player, options) {
super(player, options);

const { mainContent } = (options && options.playerOptions) || {};

this.isMainContent = mainContent;

this.update();

this.update_ = (e) => this.update(e);
Expand Down Expand Up @@ -138,7 +142,8 @@ class PosterImage extends ClickableComponent {
},
{},
Dom.createEl('img', {
loading: 'lazy',
loading: this.isMainContent ? 'eager' : 'lazy',
fetchPriority: this.isMainContent ? 'high' : 'auto',
crossOrigin: this.crossOrigin()
}, {
alt: ''
Expand Down
9 changes: 9 additions & 0 deletions test/unit/poster.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ QUnit.test('should create and update a poster image', function(assert) {
posterImage.dispose();
});

QUnit.test('should mark img as prioritized request when mainContent is true', function(assert) {
const posterImage = new PosterImage(this.mockPlayer, { playerOptions: { mainContent: true } });

assert.equal(posterImage.$('img').loading, 'eager', 'img is loading eager');
assert.equal(posterImage.$('img').fetchPriority, 'high', 'img has fetchpriority high');

posterImage.dispose();
});

QUnit.test('should mirror crossOrigin', function(assert) {
assert.strictEqual(this.mockPlayer.posterImage.$('img').crossOrigin, null, 'crossOrigin not set when not present in options');
assert.strictEqual(this.mockPlayer.posterImage.crossOrigin(), null, 'crossOrigin not set from getter when not present in options');
Expand Down
Loading