403Webshell
Server IP : 104.21.14.103  /  Your IP : 3.128.199.197
Web Server : LiteSpeed
System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : giankuin ( 1871)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/softaculous/sitepad/editor/site-data/plugins/pagelayer/js/react/src/components/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/softaculous/sitepad/editor/site-data/plugins/pagelayer/js/react/src/components/image.js
import { LabelControl } from './label';
import { MediaUpload } from '@wordpress/block-editor';
import { useState, useEffect, useRef } from '@wordpress/element';

const blankImg = pagelayer_url+'/images/default-image.png';

export const ImageControl = (props) =>{
		
	const { attributes, prop, value, setAttributes, allow = [ 'image' ]} = props;
	const { name } = prop['c'];
	const tmpAtts = attributes?.tmpAtts ?  {...attributes.tmpAtts} : {};
	
	var url = pagelayer_empty(tmpAtts[name+'-url']) ? '' : tmpAtts[name+'-url'];
	
	const onSelectImage = (imageProps) => {
		const { id, url, title, alt, sizes } = imageProps;
		
		var sizeUrls = {};
		
		// Keep a list of all sizes
		for(var x in sizes){
			sizeUrls[name+'-'+x+'-url'] = sizes[x].url;
		}
		
		const tmp = {
			...tmpAtts,
			[name+'-url']: url,
			[name+'-title']: title,
			[name+'-alt']: alt,
			[name+'-no-image-set']: '',
			...sizeUrls
		};
		
		setAttributes({
			[name]: id,
			tmpAtts: tmp
		});
		
		setAttributes({ ['pagelayer-srcset']: url+', '+url+' 1x'});
	}
	
	const onRemoveImage = (e) => {
		e.stopPropagation();
		
		const tmp = {...tmpAtts};
		
		Object.keys(tmp).forEach(key => {
		  if (key.startsWith(name + '-')) {
				delete tmp[key];
		  }
		});
		
		tmp[name+'-no-image-set'] = 1;
		tmp[name+'-url'] = blankImg;
		
		setAttributes({
			[name]: blankImg,
			tmpAtts: tmp
		});
	}
	
	const renderMediaUploader = (open) => {
		const hasImage = !pagelayer_empty(url) ? 'pagelayer-has-image' : '';
		return (
			<div
				className={`pagelayer-elp-image-div ${hasImage}`}
				style={ {backgroundImage: `url("${url}")`} }
				onClick={ () => {open()} }
			>
				<span 
					className="pagelayer-elp-remove-image"
					onClick={onRemoveImage}
				><i className="pli pli-cross" ></i></span>
				<span 
					className="pagelayer-elp-add-image"
				><i className="dashicons dashicons-plus-alt2" ></i></span>				
			</div>
		);
	}
	
	return (
		<div className="components-base-control pagelayer-base-control">
			<LabelControl {...props}/>
				<MediaUpload
					title="Select Image"
					onSelect={ onSelectImage }
					allowedTypes={ allow }
					value={ value }
					render={ ( { open } ) => renderMediaUploader( open ) }
				/>
		</div>
	);	
}

Youez - 2016 - github.com/yon3zu
LinuXploit