Cloudinary::html_attrs PHP Method

html_attrs() public static method

public static html_attrs ( $options, $only = NULL )
    public static function html_attrs($options, $only = NULL)
    {
        $attrs = array();
        foreach ($options as $k => $v) {
            $key = $k;
            $value = $v;
            if (is_int($k)) {
                $key = $v;
                $value = "";
            }
            if (is_array($only) && array_search($key, $only) !== FALSE || !is_array($only)) {
                $attrs[$key] = $value;
            }
        }
        ksort($attrs);
        $join_pair = function ($key, $value) {
            $out = $key;
            if (!empty($value)) {
                $out .= '=\'' . $value . '\'';
            }
            return $out;
        };
        return implode(" ", array_map($join_pair, array_keys($attrs), array_values($attrs)));
    }

Usage Example

コード例 #1
0
ファイル: Helpers.php プロジェクト: uiDeveloper116/webstore
 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;
 }
All Usage Examples Of Cloudinary::html_attrs