1(self.webpackChunkhappymedia=self.webpackChunkhappymedia||[]).push([[452],{126:function(){const e=jQuery;let t=!1,a={id:"",mimeType:"",url:"",size:"",dimensions:"",replaceType:""},i={size:"",dimensions:""};function n(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB","GB","TB"][t]}function r(t){const r=t.target.files[0];if(r){let t=document.getElementById("hmir_warning"),l=document.getElementById("hmir_warning_message");if(!m(r.name))return l.innerHTML='You may only upload (<span class="hmir-min-type">.png, .jpg or .gif</span>) image file.',void(t.style.display="flex");if(r.type!==a.mimeType)return l.innerHTML=`The replacement file does not have the same file type. Please select a (<span class="hmir-min-type">${o(a.mimeType)}</span>) image file for proper metadata generation.`,void(t.style.display="flex");t.style.display="none";let d=document.getElementById("hmir_submit");const h=new FileReader;h.onload=function(t){const a=document.createElement("img");a.src=t.target.result,a.onload=function(){const t=document.getElementById("hmImagePreview");e("#hmir_new_image_upload").hide(),t.appendChild(a),document.getElementById("hmir_img_weight").innerText=`Size: ${n(r.size)}`,document.getElementById("hmir_img_size").innerText=`Dimension: ${a.naturalWidth}x${a.naturalHeight}`,i.size=n(r.size),i.dimensions=`${a.naturalWidth}x${a.naturalHeight}`,e(".hmir-change-new-image").show(),e(d).removeClass("hmir-upload-btn-disabled"),d.disabled=!1}},s(),h.readAsDataURL(r)}}function m(e){return/\.(png|jpe?g|gif)$/i.test(e)}function o(e){let t=e.split("/");if(t.length>0)return"jpeg"==t[1]||"jpg"==t[1]?"jpg or jpeg":t[1]}function s(){const t=e(".hmir-error-msg");setTimeout((function(){t.length>0&&(""!=i.dimensions&&a.dimensions!=i.dimensions?t.show():t.hide())}),100)}e(document).ready((function(){function l(t,a){let i=a.url;i=i.replaceAll("-scaled",""),i=i.replace(/\.(jpg|jpeg|png|svg|gif|bmp|webp|tiff|ico)$/i,"");let n=t.find('[src^="'+i+'"]');return n.length>0&&(n.each((function(t,i){let n=e(i),r=n.attr("src"),m=n.attr("srcset");m&&(m=m.replaceAll(/\.(jpg|jpeg|png|svg|gif|bmp|webp|tiff|ico)(?=\s|$)/gi,`.${a.ext}?no_cache=1&`+Math.ceil(100*Math.random())+"="+Math.ceil(1e4*Math.random())),n.attr("srcset",m)),url=new URL(r),url.searchParams.set("no_cache",1),url.searchParams.set(Math.ceil(100*Math.random()),Math.ceil(1e4*Math.random())),n.attr("src",url)})),!0)}e(window).on("load",(function(t){setTimeout((function(){let t=e("iframe");if(t.length>0){let e=t.contents(),a=localStorage.getItem("hm_replace_image_data");if(null!=a){a=JSON.parse(a);l(e,a)}}else{let t=localStorage.getItem("hm_replace_image_data");if(null!=t){t=JSON.parse(t);l(e(document),t)}}}),500)})),e(document).on("ajaxSend",(function(e,a,i){"string"==typeof i.data&&""!=i.data&&t&&-1!=i.data.indexOf("action=query-attachments")&&(i.data+="&no_cache=1"),t=!1})),e(".hmir-upload-btn").prop("disabled",!0),e(".hm-replace-modal-close").on("click",(function(){e("#hm_image_replace_modal").hide(),e(".hmir-error").hide(),e(".hmir-warning").hide(),e("#hmir_submit").addClass("hmir-upload-btn-disabled"),e("#hmir_submit").prop("disabled",!0),i.dimensions="",i.size="",s()})),"undefined"!=typeof wp&&wp.media&&wp.media.view.Modal.prototype.on("open",(function(){setTimeout((function(){let t=e(".edit-attachment-frame .thumbnail-image img.details-image");if(t.length){let e=t.attr("src"),a=new URL(e);a.searchParams.append(Math.ceil(100*Math.random()),Math.ceil(1e3*Math.random())),t.attr("src",a)}}),500)}));const d=e("#hmImagePreview");d.on("dragenter dragover dragleave drop",(function(e){e.preventDefault(),e.stopPropagation()})),d.on("dragenter dragover",(function(){e(this).addClass("highlight")})),d.on("dragleave drop",(function(){e(this).removeClass("highlight")})),d.on("drop",(function(t){!function(t){t.preventDefault(),t.stopPropagation(),e("#hmImagePreview img").remove(),e("#hmir_new_image_upload").show(),e("#hmir_img_weight").text(""),e("#hmir_img_size").text("");const r=t.dataTransfer.files[0];
1if(r){let l=document.getElementById("hmir_warning"),d=document.getElementById("hmir_warning_message");if(!m(r.name))return d.innerHTML='You may only upload (<span class="hmir-min-type">.png, .jpg or .gif</span>) image file.',void(l.style.display="flex");if(r.type!==a.mimeType)return d.innerHTML=`The replacement file does not have the same file type. Please select a (<span class="hmir-min-type">${o(a.mimeType)}</span>) image file.`,void(l.style.display="flex");l.style.display="none";document.getElementById("hm_replace_file_input").files=t.dataTransfer.files;let h=document.getElementById("hmir_submit");const c=new FileReader;c.onload=function(t){const a=document.createElement("img");a.src=t.target.result,a.onload=function(){const t=document.getElementById("hmImagePreview");e("#hmir_new_image_upload").hide(),t.appendChild(a),document.getElementById("hmir_img_weight").innerText=`Size: ${n(r.size)}`,document.getElementById("hmir_img_size").innerText=`Dimension: ${a.naturalWidth}x${a.naturalHeight}`,e(".hmir-change-new-image").show(),h.disabled=!1,e(h).removeClass("hmir-upload-btn-disabled"),i.size=n(r.size),i.dimensions=`${a.naturalWidth}x${a.naturalHeight}`}},s(),c.readAsDataURL(r)}}(t.originalEvent)})),e("#hmir_cancel_warning").on("click",(function(){e("#hmir_warning").hide()}));let h=e("#hmir_cancel_error");h.length&&h.on("click",(function(){e("#hmir_error").hide()})),e("#hm_replace_file_input").on("change",r),e("#hmir_upload_media_btn").on("click",(function(){e("#hm_replace_file_input").click()})),e(".hmir-change-new-image").on("click",(function(t){t.preventDefault(),e("#hmImagePreview img").remove(),e("#hmir_new_image_upload").show(),e("#hmir_img_weight").text(""),e("#hmir_img_size").text(""),e("#hmir_submit").addClass("hmir-upload-btn-disabled"),e("#hmir_submit").prop("disabled",!0),e(this).hide(),i.dimensions="",i.size="",s()})),e("#hmir_submit").on("click",(function(i){i.preventDefault();let n=e(this);n.text("Please Wait..").prop("disabled",!0),n.addClass("hmir-upload-btn-disabled");let r=new FormData,m=e('input[name="hmir_replace_type"]:checked').val(),o=e("#hm_replace_file_input")[0];if(!(o.files.length>0))return e(".hmir-error").show(),e(".hmir-error-message").text(response.data.error),n.text("Submit").prop("disabled",!1),void n.removeClass("hmir-upload-btn-disabled");r.append("user_new_file",o.files[0]),r.append("action","hm_replace_and_upload_file"),r.append("attachment_id",a.id),r.append("hmir_replace_type",m),a.replaceType=m,localStorage.setItem("hm_replace_image_data",JSON.stringify(a)),e.ajax({type:"POST",url:HappyMedia.ajaxUrl,data:r,processData:!1,contentType:!1,cache:!1,headers:{"Cache-Control":"no-cache"},dataType:"json",success:function(a){if(a.success){const a=function(e){const t=new URL(e);return t.origin+t.pathname}(window.location.href);if(a.includes("upload.php")&&"undefined"!=typeof wp&&wp.media&&wp.media.frame&&wp.media.frame.close(),"undefined"!=typeof wp&&wp.media&&wp.media.frame){let e=wp.media.frame.state().get("library");e&&(t=!0,e._requery(!0))}let i=new URL(window.location.href),r=i.searchParams.get("post"),m=i.searchParams.get("action");"list"==i.searchParams.get("mode")&&(i.searchParams.set("mode","list"),window.location.reload(!0)),r&&"edit"===m&&e("body").hasClass("post-type-attachment")&&setTimeout((function(){e("img").each((function(){var t=e(this).attr("src");if(t){let a=new URL(t);a.searchParams.append(Math.ceil(100*Math.random()),Math.ceil(1e3*Math.random())),e(this).attr("src",a)}}))}),1500);const o=new CustomEvent("imageReplaceSuccess",{detail:{type:"undefined"!=typeof elementor?"elementor":"generic",message:"Image replaced successfully!"}});window.dispatchEvent(o),n.text("Submit").prop("disabled",!0),e("#hm_image_replace_modal").hide()}else e(".hmir-error").show(),e(".hmir-error-message").text(a.data.error),n.text("Submit").prop("disabled",!1),n.removeClass("hmir-upload-btn-disabled")},error:function(t,a,i){e(".hmir-error").show(),n.text("Submit").prop("disabled",!1),n.removeClass("hmir-upload-btn-disabled")}})}))})),window.hmImageReplace=function(t){if(!t.attachmentId)return;if(!t.mimeType)return;a.id=t.attachmentId,a.mimeType=t.mimeType,a.url=t.url,a.dimensions=t.attachmentMetadata.dimensions,a.size=t.attachmentMetadata.size,a.ext=t.attachmentMetadata.ext;let i=new URL(t.url);i.searchParams.append(Math.ceil(100*Math.random()),Math.ceil(1e3*Math.random())),e(document.body).addClass("hmir-replace-image-modal-elementor"),e("#hm_image_replace_modal").show(),e("#hmImagePreview img").remove(),e(".hmir-change-new-image").hide(),e("#hmir_new_image_upload").show(),e("#hmir_img_weight").text(""),e("#hmir_img_size").text(""),e(".hmir-old-image-name").text(t.attachmentMetadata.name),e(".hmir-old-image-name").attr("title",t.url),e(".hmir-old-image-size").text(`Size: ${t.attachmentMetadata.size}`),e(".hmir-old-image-dimension").text(`Dimension: ${t.attachmentMetadata.dimensions}`),e(".hmir-old-img-thumb img").attr("src",i),e(".hmir-mime-type").text(a.mimeType)}}},function(e){var t;t=126,e(e.s=t)}]);
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.