classes/Tools/Imgix/ImgixTool.php
public function saveAdjustments() {
		$image_id = esc_html($_POST['image_id']);
		$size = esc_html($_POST['size']);
		$params = (isset($_POST['settings'])) ? $_POST['settings'] : [];

		if(!current_user_can('edit_post', $image_id)) {
			json_response([
				              'status' => 'error',
				              'message' => 'You are not strong enough, smart enough or fast enough.'
			              ]);
		}


		$meta = wp_get_attachment_metadata($image_id);
		if(!$meta) {
			json_response([
				              'status' => 'error',
				              'message' => 'Invalid image id.'
			              ]);
		}

		if($size == 'full') {
			$meta['imgix-params'] = $params;
		} else {
			$meta['imgix-size-params'][$size] = $params;
		}

		wp_update_attachment_metadata($image_id, $meta);

		json_response([
			              'status' => 'ok'
		              ]);
	}
public function saveAdjustments() {
		$image_id = esc_html($_POST['image_id']);
		$size = esc_html($_POST['size']);
		$params = (isset($_POST['settings'])) ? $_POST['settings'] : [];

		if(!current_user_can('edit_post', $image_id)) {
			json_response([
				              'status' => 'error',
				              'message' => 'You are not strong enough, smart enough or fast enough.'
			              ]);
		}


		$meta = wp_get_attachment_metadata($image_id);
		if(!$meta) {
			json_response([
				              'status' => 'error',
				              'message' => 'Invalid image id.'
			              ]);
		}

		if($size == 'full') {
			$meta['imgix-params'] = $params;
		} else {
			$meta['imgix-size-params'][$size] = $params;
		}

		wp_update_attachment_metadata($image_id, $meta);

		json_response([
			              'status' => 'ok'
		              ]);
	}
public function saveAdjustments ( ) { $ image_id = esc_html ( $ _POST [ 'image_id' ] ) ; $ size = esc_html ( $ _POST [ 'size' ] ) ; $ params = ( isset ( $ _POST [ 'settings' ] ) ) ? $ _POST [ 'settings' ] : [ ] ; if ( ! current_user_can ( 'edit_post' , $ image_id ) ) { json_response ( [ 'status' => 'error' , 'message' => 'You are not strong enough, smart enough or fast enough.' ] ) ; } $ meta = wp_get_attachment_metadata ( $ image_id ) ; if ( ! $ meta ) { json_response ( [ 'status' => 'error' , 'message' => 'Invalid image id.' ] ) ; } if ( $ size == 'full' ) { $ meta [ 'imgix-params' ] = $ params ; } else { $ meta [ 'imgix-size-params' ] [ $ size ] = $ params ; } wp_update_attachment_metadata ( $ image_id , $ meta ) ; json_response ( [ 'status' => 'ok' ] ) ; }
Save The Parameters
Save The Parameters