Skip to content

Instantly share code, notes, and snippets.

@fyrebase
Last active May 11, 2016 10:27
Show Gist options
  • Select an option

  • Save fyrebase/d1d35f3ee590f250eee11b974a627c76 to your computer and use it in GitHub Desktop.

Select an option

Save fyrebase/d1d35f3ee590f250eee11b974a627c76 to your computer and use it in GitHub Desktop.

Revisions

  1. fyrebase revised this gist May 11, 2016. No changes.
  2. fyrebase created this gist May 11, 2016.
    12 changes: 12 additions & 0 deletions gist.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    <?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';
    }
    }
    });