PHP code example of 3xw / attachment-third-party

1. Go to this page and download the library: Download 3xw/attachment-third-party library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

3xw / attachment-third-party example snippets


// Queue
$this->addPlugin('Queue');

return [
	'Attachment' => [

		//...

		'listeners' => [
			'beforeSave' => [
				'Attachment\Listener\ModifyTypeListener' => [
					'type' => 'transit',
					'subtype' => 'youtube', // or other third party name
				]
			],
		]

		//...

	]
];

$this->Attachment->buildIndex([
	'actions' => ['add','edit','delete','view'],
	'types' =>['image/jpeg','image/png','embed/youtube','embed/vimeo','video/quicktime','transit/youtube'],
	'listeners' => [
		'beforeSave' => [
			'Attachment\Listener\ModifyTypeListener' => [
				'type' => 'transit',
				'subtype' => 'youtube',
			]
		],
	]
])