Answers.Body: <p>Here's how i solved it:</p>
  
  <pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Asset);
  $criteria-&gt;id = $assetId;
  $elements = $criteria-&gt;find();
  $element[0]-&gt;getContent()-&gt;title = 'New Title';
  craft()-&gt;elements-&gt;saveElement($element[0]);
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-12T19:12:36.437Z
Answers.Text: Can you check this answer as best answer?
Answers.UserDisplayName: mohd4482
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-03T19:25:20.427Z
Answers.LastActivityDate: 2015-04-03T19:25:20.427Z
Answers.UserDisplayName: phaetons
Body: <p>I save image files from within my plugin through <code>assets-&gt;insertFileByLocalPath()</code>. 
  Unfortunately, i can't give the image title as paramter to the method.</p>
  
  <p>What is the easiest way to change the image title after insert, espacially considering different languages?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Ok, i found a solution (moved to the answer), but how do i save values for different languages?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-02T22:33:11.657Z
Comments.Text: You should post that as an answer! To select a specific locale you would add `$criteria.locale = "en-us"`. Although you may want to save it without locale first so that it copies the titles to all locales by default; and then retrieve the specific locale using the above, overwrite the title, and save again.
Comments.UserDisplayName: Douglas McDonald
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-03T19:22:06.453Z
Comments.Text: you're right, i will post an answer. Thanks for the hint with the locale criteria!
Comments.UserDisplayName: phaetons
Tags: <plugin-development><assets>
Title: Change image title programatically?
ThreadText: # Change image title programatically?
  
  (Asked by: username_0 on 2015-04-02)
  
  I save image files from within my plugin through `assets->insertFileByLocalPath()`.
  Unfortunately, i can't give the image title as paramter to the method.
  
  What is the easiest way to change the image title after insert, espacially considering different languages?
  
  **UPDATE**
  
  Ok, i found a solution (moved to the answer), but how do i save values for different languages?
  
  **Tags:** plugin-development, assets
  
  > **Comments:**
  > **username_1**: You should post that as an answer! To select a specific locale you would add `$criteria.locale = "en-us"`. Although you may want to save it without locale first so that it copies the titles to all locales by default; and then retrieve the specific locale using the above, overwrite the title, and save again.  
  > **username_0**: you're right, i will post an answer. Thanks for the hint with the locale criteria!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2015-04-03. Score: 1
  
  Here's how i solved it:
  
  ```
  $criteria = craft()->elements->getCriteria(ElementType::Asset);
  $criteria->id = $assetId;
  $elements = $criteria->find();
  $element[0]->getContent()->title = 'New Title';
  craft()->elements->saveElement($element[0]);
  
  ```
  
  > **Comments:**
  > **username_2**: Can you check this answer as best answer?  
  
  ---
  
  