@@ -23,6 +23,7 @@ class Item extends React.PureComponent {
2323 onClick : PropTypes . func . isRequired ,
2424 displayWidth : PropTypes . number ,
2525 visible : PropTypes . bool . isRequired ,
26+ autoplay : PropTypes . bool ,
2627 } ;
2728
2829 static defaultProps = {
@@ -48,9 +49,13 @@ class Item extends React.PureComponent {
4849 }
4950 }
5051
52+ getAutoPlay ( ) {
53+ return this . props . autoplay || autoPlayGif ;
54+ }
55+
5156 hoverToPlay ( ) {
5257 const { attachment } = this . props ;
53- return ! autoPlayGif && attachment . get ( 'type' ) === 'gifv' ;
58+ return ! this . getAutoPlay ( ) && attachment . get ( 'type' ) === 'gifv' ;
5459 }
5560
5661 handleClick = ( e ) => {
@@ -201,7 +206,7 @@ class Item extends React.PureComponent {
201206 </ a >
202207 ) ;
203208 } else if ( attachment . get ( 'type' ) === 'gifv' ) {
204- const autoPlay = ! isIOS ( ) && autoPlayGif ;
209+ const autoPlay = ! isIOS ( ) && this . getAutoPlay ( ) ;
205210
206211 thumbnail = (
207212 < div className = { classNames ( 'media-gallery__gifv' , { autoplay : autoPlay } ) } >
@@ -248,6 +253,7 @@ class MediaGallery extends React.PureComponent {
248253 defaultWidth : PropTypes . number ,
249254 cacheWidth : PropTypes . func ,
250255 visible : PropTypes . bool ,
256+ autoplay : PropTypes . bool ,
251257 onToggleVisibility : PropTypes . func ,
252258 } ;
253259
@@ -297,7 +303,7 @@ class MediaGallery extends React.PureComponent {
297303 }
298304
299305 render ( ) {
300- const { media, intl, sensitive, height, defaultWidth, standalone } = this . props ;
306+ const { media, intl, sensitive, height, defaultWidth, standalone, autoplay } = this . props ;
301307 const { visible } = this . state ;
302308
303309 const width = this . state . width || defaultWidth ;
@@ -320,9 +326,9 @@ class MediaGallery extends React.PureComponent {
320326 const uncached = media . every ( attachment => attachment . get ( 'type' ) === 'unknown' ) ;
321327
322328 if ( standalone && this . isFullSizeEligible ( ) ) {
323- children = < Item standalone onClick = { this . handleClick } attachment = { media . get ( 0 ) } displayWidth = { width } visible = { visible } /> ;
329+ children = < Item standalone autoplay = { autoplay } onClick = { this . handleClick } attachment = { media . get ( 0 ) } displayWidth = { width } visible = { visible } /> ;
324330 } else {
325- children = media . take ( 4 ) . map ( ( attachment , i ) => < Item key = { attachment . get ( 'id' ) } onClick = { this . handleClick } attachment = { attachment } index = { i } size = { size } displayWidth = { width } visible = { visible || uncached } /> ) ;
331+ children = media . take ( 4 ) . map ( ( attachment , i ) => < Item key = { attachment . get ( 'id' ) } autoplay = { autoplay } onClick = { this . handleClick } attachment = { attachment } index = { i } size = { size } displayWidth = { width } visible = { visible || uncached } /> ) ;
326332 }
327333
328334 if ( uncached ) {
0 commit comments