html_attrs() public static méthode

public static html_attrs ( $options, $only = NULL )
Exemple #1
0
 function cl_image_tag($source, $options = array())
 {
     $source = cloudinary_url_internal($source, $options);
     if (isset($options["html_width"])) {
         $options["width"] = Cloudinary::option_consume($options, "html_width");
     }
     if (isset($options["html_height"])) {
         $options["height"] = Cloudinary::option_consume($options, "html_height");
     }
     $responsive = Cloudinary::option_consume($options, "responsive");
     $hidpi = Cloudinary::option_consume($options, "hidpi");
     if ($responsive || $hidpi) {
         $options["data-src"] = $source;
         $classes = array($responsive ? "cld-responsive" : "cld-hidpi");
         $current_class = Cloudinary::option_consume($options, "class");
         if ($current_class) {
             array_unshift($classes, $current_class);
         }
         $options["class"] = implode(" ", $classes);
         $source = Cloudinary::option_consume($options, "responsive_placeholder", Cloudinary::config_get("responsive_placeholder"));
         if ($source == "blank") {
             $source = Cloudinary::BLANK;
         }
     }
     $html = "<img ";
     if ($source) {
         $html .= "src='{$source}' ";
     }
     $html .= Cloudinary::html_attrs($options) . "/>";
     return $html;
 }
 function cl_video_tag($source, $options = array())
 {
     $source = preg_replace('/\\.(' . implode('|', default_source_types()) . ')$/', '', $source);
     $source_types = Cloudinary::option_consume($options, 'source_types', array());
     $source_transformation = Cloudinary::option_consume($options, 'source_transformation', array());
     $fallback = Cloudinary::option_consume($options, 'fallback_content', '');
     if (empty($source_types)) {
         $source_types = default_source_types();
     }
     $video_options = $options;
     if (array_key_exists('poster', $video_options)) {
         if (is_array($video_options['poster'])) {
             if (array_key_exists('public_id', $video_options['poster'])) {
                 $video_options['poster'] = cloudinary_url_internal($video_options['poster']['public_id'], $video_options['poster']);
             } else {
                 $video_options['poster'] = cl_video_thumbnail_path($source, $video_options['poster']);
             }
         }
     } else {
         $video_options['poster'] = cl_video_thumbnail_path($source, $options);
     }
     if (empty($video_options['poster'])) {
         unset($video_options['poster']);
     }
     $html = '<video ';
     if (!array_key_exists('resource_type', $video_options)) {
         $video_options['resource_type'] = 'video';
     }
     $multi_source = is_array($source_types);
     if (!$multi_source) {
         $source .= '.' . $source_types;
     }
     $src = cloudinary_url_internal($source, $video_options);
     if (!$multi_source) {
         $video_options['src'] = $src;
     }
     if (isset($video_options["html_width"])) {
         $video_options['width'] = Cloudinary::option_consume($video_options, 'html_width');
     }
     if (isset($video_options['html_height'])) {
         $video_options['height'] = Cloudinary::option_consume($video_options, 'html_height');
     }
     $html .= Cloudinary::html_attrs($video_options) . '>';
     if ($multi_source) {
         foreach ($source_types as $source_type) {
             $transformation = Cloudinary::option_consume($source_transformation, $source_type, array());
             $transformation = array_merge($options, $transformation);
             $src = cl_video_path($source . '.' . $source_type, $transformation);
             $video_type = $source_type == 'ogv' ? 'ogg' : $source_type;
             $mime_type = "video/{$video_type}";
             $html .= '<source ' . Cloudinary::html_attrs(array('src' => $src, 'type' => $mime_type)) . '>';
         }
     }
     $html .= $fallback;
     $html .= '</video>';
     return $html;
 }
function cl_image_tag($source, $options = array())
{
    $source = cloudinary_url_internal($source, $options);
    if (isset($options["html_width"])) {
        $options["width"] = Cloudinary::option_consume($options, "html_width");
    }
    if (isset($options["html_height"])) {
        $options["height"] = Cloudinary::option_consume($options, "html_height");
    }
    return "<img src='" . $source . "' " . Cloudinary::html_attrs($options) . "/>";
}
 function cl_form_tag($callback_url, $options = array())
 {
     $form_options = Cloudinary::option_get($options, "form", array());
     $options["callback_url"] = $callback_url;
     $params = Cloudinary\Uploader::build_upload_params($options);
     $params = Cloudinary::sign_request($params, $options);
     $api_url = Cloudinary::cloudinary_api_url("upload", $options);
     $form = "<form enctype='multipart/form-data' action='" . $api_url . "' method='POST' " . Cloudinary::html_attrs($form_options) . ">\n";
     foreach ($params as $key => $value) {
         $form .= "<input " . Cloudinary::html_attrs(array("name" => $key, "value" => $value, "type" => "hidden")) . "/>\n";
     }
     $form .= "</form>\n";
     return $form;
 }