Answers.Body: <p>Yes, it's possible.</p>
  
  <p>It essentially works just like it does in twig...you just call <code>getURL</code> with the valid name of a transform</p>
  
  <pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Asset);
  $criteria-&gt;id = 1;
  $asset = $criteria-&gt;first();
  
  if ($asset)
  {
      $url = $asset-&gt;getUrl('myTransform');
  }
  
  $imgUrl = $image-&gt;getUrl('tranformHandle);
  </code></pre>
  
  <p>...as I understand it that triggers the  image to be transformed on-demand if the transform does not already exist.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-28T05:06:52.270Z
Answers.Text: Hum this is what I did but it does not work. I have a problem ok I will try to see in the logs.
Answers.UserDisplayName: migmaker
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-28T05:15:40.340Z
Answers.Text: OK I found it : got a problem with my permissions on the directory...
Answers.UserDisplayName: migmaker
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-28T05:16:29.020Z
Answers.Text: Glad you got it working.
Answers.UserDisplayName: Jeremy Daalder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-27T23:36:24.417Z
Answers.LastActivityDate: 2017-05-27T23:36:24.417Z
Answers.UserDisplayName: Jeremy Daalder
Body: <p>How can I trigger an image transform in a Craft plugin?</p>
  
Tags: <plugin-development><image-transforms>
Title: Image transform in a plugin
ThreadText: # Image transform in a plugin
  
  (Asked by: username_0 on 2017-05-27)
  
  How can I trigger an image transform in a Craft plugin?
  
  **Tags:** plugin-development, image-transforms
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-05-27. Score: 3 | Accepted answer
  
  Yes, it's possible.
  
  It essentially works just like it does in twig...you just call `getURL` with the valid name of a transform
  
  ```
  $criteria = craft()->elements->getCriteria(ElementType::Asset);
  $criteria->id = 1;
  $asset = $criteria->first();
  
  if ($asset)
  {
      $url = $asset->getUrl('myTransform');
  }
  
  $imgUrl = $image->getUrl('tranformHandle);
  
  ```
  
  ...as I understand it that triggers the image to be transformed on-demand if the transform does not already exist.
  
  > **Comments:**
  > **username_0**: Hum this is what I did but it does not work. I have a problem ok I will try to see in the logs.  
  > **username_0**: OK I found it : got a problem with my permissions on the directory...  
  > **username_1**: Glad you got it working.  
  
  ---
  
  