Example #1
0
 /**
  * Updates the tags associated with the given media.
  *
  * If the image can't be resized, its web and thumbnail images will
  * be symlinked to the full size image to prevent broken image sources.
  *
  * @param Media $media The Media object to associate the tags with.
  * @param array $tags An array of tag names.
  */
 private static function update_tags($media, $tags)
 {
     // Remove all existing tag associations
     Database::DELETE_FROM(TAG_RELATION_TABLE . ' WHERE image_id = ?', array($media->id));
     foreach ($tags as $tag) {
         // Skip empty tags
         if (trim($tag) == '') {
             continue;
         }
         // Create tags which don't exist yet
         if (!Tag::exists($tag)) {
             Tag::create($tag);
         }
         $media->add_tag($tag);
     }
 }