Hi all,
I'm trying to get the narrative component to work like the graphic component so you can specify a different image src for "large" or "small" screens. I've added the resizeImage() function from the graphic JS file to the narrative JS file and modified it (see below). Only problem is the component is now not finding the default image src, so the narrative-slider-graphic is blank.
Could anyone help to explain where I'm going wrong?! Is there something wrong with this.model.get('_items._graphic')
? (PS. As well as the code below, I also added a function to call resizeImage() in the preRender() and postRender() functions)
resizeImage: function(width, setupInView) {
var imageWidth = width === 'medium' ? 'small' : width;
var imageSrc = (this.model.get('_items._graphic')) ? this.model.get('_items._graphic')[imageWidth] : '';
this.$('.narrative-slider-graphic img').attr('src', imageSrc);
this.$('.narrative-widget').imageready(_.bind(function() {
this.setReadyStatus();
if (setupInView) {
// Bind 'inview' once the image is ready.
this.$('.component-widget').on('inview', _.bind(this.inview, this));
}
}, this));
}