Sid Gifari File Manager
🏠 Root
/
home
/
caldereriajp
/
www
/
wp-content
/
plugins
/
all-in-one-seo-pack
/
dist
/
Lite
/
assets
/
js
/
Editing: Image.8dc068b7.js
import{t as g,v as h,s as f,k as l,w as $,x as E,u as p,c as _,f as v}from"./links.96235554.js";import{g as P,a as U,c as I,b as x}from"./postContent.314c716d.js";const O=()=>{var e;let t=0;return(g()||h())&&(t=parseInt((e=document.getElementById("post_author_override"))==null?void 0:e.value)),f()&&(t=window.wp.data.select("core/editor").getEditedPostAttribute("author")),t},y=()=>{const t=document.querySelector("#set-post-thumbnail img");return t?t.getAttribute("src"):""},S=async(t=!1)=>{const e=window.wp.data.select("core/editor"),i=t?e.getEditedPostAttribute("featured_media"):e.getCurrentPost().featured_media;return typeof i>"u"?new Promise(a=>setTimeout(()=>a(S(t)),1e3)):i},w=async()=>{if(g()||h())return y();if(f()){const t=await S(!0).then(i=>i);return isNaN(t)||t===0?"":l().getMediaData({mediaId:t}).then(i=>i.source_url)}return $()?P().featuredImage:E()?U().featuredImage:""},B={emits:["updateSocialImagePreview"],data(){return{excludedTermOptions:["featured","attach","content","author","auto"],excludedAttachmentOptions:["featured","content","author"],excludedPageBuilderOptions:["auto"]}},computed:{imageSourceOptions(){return[{label:this.$t.__("Default Image (Set Below)",this.$td),value:"default"},{label:this.$t.__("Featured Image",this.$td),value:"featured"},{label:this.$t.__("Attached Image",this.$td),value:"attach"},{label:this.$t.__("First Image in Content",this.$td),value:"content"},{label:this.$t.__("Image from Custom Field",this.$td),value:"custom"},{label:this.$t.__("Post Author Image",this.$td),value:"author"},{label:this.$t.__("First Available Image",this.$td),value:"auto"}]},imageSourceOptionsFiltered(){var a,s,r;const t=l(),e=this.imageSourceOptions.map(o=>(o.value==="default"&&(o.label=this.$t.__("Default Image Source (Set in Social Networks)",this.$td)),o)).concat({label:this.$t.__("Custom Image",this.$td),value:"custom_image"});if(((a=t.currentPost)==null?void 0:a.context)==="term")return e.filter(o=>!this.excludedTermOptions.includes(o.value));if(((s=t.currentPost)==null?void 0:s.context)==="post"&&((r=t.currentPost)==null?void 0:r.postType)==="attachment")return e.filter(o=>!this.excludedAttachmentOptions.includes(o.value));const i=p();return i.aioseo.integration?(i.aioseo.integration==="seedprod"&&this.excludedPageBuilderOptions.push("featured","custom"),e.filter(o=>!this.excludedPageBuilderOptions.includes(o.value))):e}},methods:{getTermImageSourceOptions(){return this.imageSourceOptions.filter(t=>!this.excludedTermOptions.includes(t.value))},getImageSourceOption(t){return this.imageSourceOptions.find(e=>e.value===t)},getImageSourceOptionFiltered(t){return this.imageSourceOptionsFiltered.find(e=>e.value===t)}}},b=()=>{let t=null;const e=/<img.*?src=['"](.*?)['"].*?>/i.exec(x());return e&&e[1]&&(t=e[1]),t},k=async(t,e,i)=>{let a=I(t[`${i}image_custom_fields`]);return a||await w().then(s=>{a=s}),a||await l().getFirstAttachedImage({postId:t.id}).then(r=>{a=r}),a||(a=b()),a||(a=_().options.social[e].homePage.image),a},A=async()=>{let t="";const e=O();return await l().getUserImage({userId:e}).then(a=>{t=a}),t},T={data(){return{imageUrl:"",loading:!1}},async mounted(){await this.setImageUrl()},methods:{async setImageUrl(t=""){var m;const e=_(),i=l(),a=v(),s=i.currentPost,r=t||((m=a.metaBoxTabs)==null?void 0:m.social)||"facebook",o=r==="facebook"||r==="twitter"&&s.twitter_use_og?"og_":"twitter_";let c=s[`${o}image_type`]||"default";switch(c==="default"&&(c=e.options.social[r].general.defaultImageSourcePosts),this.imageUrl="",c){case"featured":this.loading=!0,await w().then(n=>{this.imageUrl=n,this.loading=!1});break;case"attach":this.loading=!0,await i.getFirstAttachedImage({postId:s.id}).then(n=>{this.imageUrl=n,this.loading=!1});break;case"content":this.imageUrl=b();break;case"author":this.loading=!0,await A().then(n=>{this.imageUrl=n,this.loading=!1});break;case"auto":this.loading=!0,await k(s,r,o).then(n=>{this.imageUrl=n,this.loading=!1});break;case"custom":this.imageUrl=I(s[`${o}image_custom_fields`]);break;case"custom_image":this.imageUrl=s[`${o}image_custom_url`];break;case"default":default:this.imageUrl=e.options.social[r].general.defaultImagePosts;break}const d=p();!this.imageUrl&&d.aioseo.urls.siteLogo&&(this.imageUrl=d.aioseo.urls.siteLogo),window.aioseoBus.$emit("updateSocialImagePreview",{social:r,image:this.imageUrl})}}},u={},D={methods:{async openUploadModal(t,e){const i=()=>{const a=u[t].state().get("selection").first().toJSON();e(a.url)};if(u[t]){u[t].open();return}u[t]=window.wp.media({title:this.$t.__("Choose Image",this.$td),button:{text:this.$t.__("Choose Image",this.$td)},multiple:!1}),u[t].on("select",i),await this.$nextTick(),u[t].open()}}};export{B as I,D as U,T as a};
Save
Cancel