/** * Determines if a file of the given type can be added to an Ad based solely * on the number of files of the same type that are already attached to * the Ad. * * @since 3.0.2 * @deprecated 3.4 */ function awpcp_can_upload_file_to_ad($file, $ad) { $stats = awpcp_get_ad_uploaded_files_stats($ad); $image_mime_types = awpcp_get_image_mime_types(); $images_allowed = $stats['images_allowed']; $images_uploaded = $stats['images_uploaded']; $result = true; if (in_array($file['type'], $image_mime_types)) { if ($images_allowed <= $images_uploaded) { $result = _x("You can't add more images to this Ad. There are not remaining images slots.", 'upload files', 'AWPCP'); } } return apply_filters('awpcp-can-upload-file-to-ad', $result, $file, $ad, $stats); }
public function is_image() { return in_array($this->mime_type, awpcp_get_image_mime_types()); }
private function get_files($ad) { $allowed_mime_types = awpcp_get_allowed_mime_types(); $image_mime_types = awpcp_get_image_mime_types(); $files = awpcp_media_api()->find_by_ad_id($ad->ad_id, array('order' => array('mime_type ASC', 'id ASC'))); $groups = array(); foreach ($files as $file) { $extension = strtolower(awpcp_get_file_extension($file->name)); $mime_type = $file->mime_type; if (!in_array($mime_type, $allowed_mime_types)) { continue; } else { if (in_array($mime_type, $image_mime_types)) { $groups['images'][] = $file; } else { $groups[$extension][] = $file; } } } return $groups; }
public function find_images_by_ad_id($ad_id, $args = array()) { $mime_types = awpcp_get_image_mime_types(); return self::query(array_merge($args, array('ad_id' => $ad_id, 'mime_type' => $mime_types))); }