1(function ($, Drupal) { 2 'use strict'; 3 4 5 Drupal.behaviors.image_caption = { 6 attach: function (context, settings) { 7 8 $(".node--view-mode-full img:not(.caption-processed)").each(function(i) { 9 var imgwidth = $(this).width() ? $(this).width() : false; 10 var imgheight = $(this).height() ? $(this).height() : false; 11 12 // Get caption from title attribute 13 var captiontext = $(this).attr('title'); 14 15 // Get image alignment and style to apply to container 16 if (captiontext) { 17 if($(this).attr('align')){ 18 var alignment = $(this).attr('align'); 19 $(this).css({'float':alignment}); // add to css float 20 $(this).removeAttr('align'); 21 }else if($(this).css('float')){ 22 var alignment = $(this).css('float'); 23 }else{ 24 var alignment = 'normal'; 25 } 26 var style = $(this).attr('style') ? $(this).attr('style') : ''; 27 28 // Reset img styles as are added to container instead 29 $(this).removeAttr('width'); 30 $(this).removeAttr('height'); 31 $(this).css('width', ''); 32 $(this).css('height', ''); 33 $(this).removeAttr('align'); 34 $(this).removeAttr('style'); 35 36 //Display inline block so it doesn't break any text aligns on the parent contatiner 37 $(this).wrap("<span class=\"image-caption-container\" style=\"display:inline-block;" + style + "\"></span>"); 38 $(this).parent().addClass('image-caption-container-' + alignment); 39 40 // Add dimensions, if available 41 if(imgwidth){ 42 $(this).width(imgwidth); 43 $(this).parent().width(imgwidth); 44 } 45 if(imgheight){ 46 $(this).height(imgheight); 47 } 48 // Append caption 49 $(this).parent().append("<span style=\"display:block;\" class=\"image-caption\">" + captiontext + "</span>"); 50 51 // Add class to prevent duplicate caption adding 52 $(this).addClass('caption-processed'); 53 } 54 }); 55 } 56 }; 57 58}(jQuery, Drupal));
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.