Last active
May 11, 2016 10:27
-
-
Save fyrebase/d1d35f3ee590f250eee11b974a627c76 to your computer and use it in GitHub Desktop.
Craft CMS generate asset title before save
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
craft()->on('assets.beforeSaveAsset', function(Event $event) { | |
if ($event->params['isNewAsset']) { | |
$asset = $event->params['asset']; | |
$source = $asset->getSource(); | |
if (in_array($source->handle, ['myAssetSource'])) { | |
$asset->getContent()->title = 'myAssetTitle'; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment