| @@ -1,37 +1,6 @@ | ||
| 1 | 1 | /* global jetpackSlideshowSettings */ |
| 2 | 2 | |
| 3 | -/** | |
| 4 | - * Turn a gallery caption into the plain text it is meant to be. | |
| 5 | - * | |
| 6 | - * A caption is meant to read as text, but wptexturize() leaves HTML entities behind, so it needs | |
| 7 | - * decoding before it can be set as one. | |
| 8 | - * | |
| 9 | - * @param {*} caption - Caption value from the gallery data. | |
| 10 | - * @return {string} The decoded caption, as text. | |
| 11 | - */ | |
| 12 | -function jetpackSlideshowCaptionText( caption ) { | |
| 13 | - if ( typeof caption !== 'string' || '' === caption ) { | |
| 14 | - return ''; | |
| 15 | - } | |
| 16 | - | |
| 17 | - var parsed = new DOMParser().parseFromString( caption, 'text/html' ); | |
| 18 | - | |
| 19 | - // These land in the body when they appear mid-caption, and their source is not caption text. | |
| 20 | - parsed.body | |
| 21 | - .querySelectorAll( 'script, style, noscript, template' ) | |
| 22 | - .forEach( function ( element ) { | |
| 23 | - element.remove(); | |
| 24 | - } ); | |
| 25 | - | |
| 26 | - // Without a space in its place, a caption broken over two lines reads as "Ada LovelaceLondon". | |
| 27 | - parsed.body.querySelectorAll( 'br' ).forEach( function ( element ) { | |
| 28 | - element.replaceWith( ' ' ); | |
| 29 | - } ); | |
| 30 | - | |
| 31 | - return parsed.body.textContent; | |
| 32 | -} | |
| 33 | - | |
| 34 | 3 | function JetpackSlideshow( element, transition, autostart ) { |
| 35 | 4 | this.element = element; |
| 36 | 5 | this.images = []; |
| 37 | 6 | this.controls = {}; |
| @@ -69,9 +38,9 @@ | ||
| 69 | 38 | img.nopin = 'nopin'; |
| 70 | 39 | var caption = document.createElement( 'div' ); |
| 71 | 40 | caption.className = 'jetpack-slideshow-slide-caption'; |
| 72 | 41 | caption.setAttribute( 'itemprop', 'caption description' ); |
| 73 | - caption.textContent = jetpackSlideshowCaptionText( imageInfo.caption ); | |
| 42 | + caption.innerHTML = imageInfo.caption; | |
| 74 | 43 | var container = document.createElement( 'div' ); |
| 75 | 44 | container.className = 'jetpack-slideshow-slide'; |
| 76 | 45 | container.setAttribute( 'itemprop', 'associatedMedia' ); |
| 77 | 46 | container.setAttribute( 'itemscope', '' ); |