| Server IP : 38.190.208.107 / Your IP : 216.73.217.51 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.10/wp-content/themes/blocksy/static/js/options/options/ |
Upload File : |
import { createElement, Component, Fragment } from '@wordpress/element'
import classnames from 'classnames'
import { __ } from 'ct-i18n'
import _ from 'underscore'
import { applyFilters } from '@wordpress/hooks'
const ALLOWED_MEDIA_TYPES = ['image']
export default class MultiImageUploader extends Component {
params = {
height: 250,
width: 250,
flex_width: true,
flex_height: true,
}
state = {
attachment_info: [],
}
getUrlFor = (attachmentInfo) =>
attachmentInfo
? (attachmentInfo.width < 700
? attachmentInfo.sizes.full
: _.max(
_.values(
_.keys(attachmentInfo.sizes).length === 1
? attachmentInfo.sizes
: _.omit(attachmentInfo.sizes, 'full')
),
({ width }) => width
)
).url || attachmentInfo.url
: null
render() {
const actions = applyFilters(
'blocksy.options.ct-multi-image-uploader.actions',
[
({ props, attachment: { attachment_id } }) => (
<button
title="Remove"
type="button"
className="button remove-button"
onClick={(e) => {
e.stopPropagation()
props.onChange(
props.value.filter(
(a) => a.attachment_id !== attachment_id
)
)
}}></button>
),
]
)
return (
<div
className={classnames('ct-attachment-multi', {})}
{...(this.props.option.attr || {})}>
<wp.mediaUtils.MediaUpload
onSelect={(media) => {
const result = media.map((attachment) => ({
url: this.getUrlFor(attachment),
attachment_id: attachment.id,
}))
this.props.onChange(result)
}}
gallery={true}
allowedTypes={ALLOWED_MEDIA_TYPES}
value={this.props.value.map(
({ attachment_id }) => attachment_id
)}
multiple={true}
render={({ open }) => (
<Fragment>
{Array.isArray(this.props.value) &&
this.props.value.length > 0 && (
<div className="ct-thumbnails-list">
{this.props.value.map(
({
url,
attachment_id,
...attachment
}) => (
<div
key={attachment_id}
className="thumbnail thumbnail-image"
onClick={() => {
open()
}}>
<img
className="attachment-thumb"
src={url}
draggable="false"
alt=""
/>
<ul className="actions">
{actions.map(
(a, index) => (
<li key={index}>
{a({
props: this
.props,
attachment:
{
...attachment,
url,
attachment_id,
},
})}
</li>
)
)}
</ul>
</div>
)
)}
</div>
)}
<button
type="button"
className="button edit-button control-focus"
title="Edit"
onClick={() => open()}>
{__('Add/Edit Gallery', 'blocksy')}
</button>
</Fragment>
)}
/>
</div>
)
}
}