1(function ($) { 2 'use strict'; 3 $('img[longdesc]').each(function () { 4 var longdesc = $(this).attr('longdesc'); 5 var alt = $(this).attr('alt'); 6 var classes = $(this).attr('class'); 7 $(this).wrap('<div class="wpa-ld" />'); 8 $(this).parent('.wpa-ld').addClass(classes); 9 $(this).attr('alt', '').attr('class', ''); 10 $(this).parent('.wpa-ld').append('<a href="' + longdesc + '" class="longdesc-link">Description<span> of' + alt + '</span></a>'); 11 }); 12 13 $( 'figure.is-style-longdesc' ).each(function() { 14 var img = $(this).find( 'img' ); 15 wpa_load_image( img ); 16 }); 17 18 function wpa_draw_longdesc( img, image_id, longdesc ) { 19 var alt = img.attr('alt'); 20 var post_classes = document.body.className.split(/\s+/); 21 var post_id = ''; 22 console.log( post_classes ); 23 $.each( post_classes, function ( index, value ) { 24 if ( value.match( /postid-/gi ) ) { 25 post_id = value.replace( 'postid-', '', value ); 26 } 27 }); 28 var url = new URL(longdesc); 29 url.searchParams.set('referrer',post_id ); 30 url.toString(); 31 var classes = img.attr('class'); 32 img.wrap('<div class="wpa-ld" />');
33 img.parent('.wpa-ld').addClass(classes); 34 img.attr('alt', '').attr('class', ''); 35 img.parent('.wpa-ld').append('<a href="' + url + '" class="longdesc-link">Description<span> of' + alt + '</span></a>'); 36 } 37 38 function wpa_load_image( img ) { 39 var id = img.attr( 'class' ).replace( 'wp-image-', '' ); 40 var api = wparest.url + '/' + id; 41 42 $.get( api ) 43 .done( function( response ) { 44 var attachment = { 45 attachment: response 46 } 47 var rawdesc = response.description.rendered; 48 rawdesc = rawdesc.replace(/(<([^>]+)>)/gi, '').trim(); 49 if ( '' !== rawdesc ) { 50 var url = new URL( response.link ); 51 url.searchParams.set( 'longdesc', id ); 52 url.toString(); 53 wpa_draw_longdesc( img, id, url ); 54 } 55 }) 56 .fail( function() { 57 alert( 'cannot load media' ) 58 }); 59 } 60}(jQuery));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.