Derrived method to create <img />

@param mixed $attr Hash array with tag attributes or string with image source (src)

@return string HTML code
@see html::tag()
760026
public static function img($attr = null)
    {
        if (is_string($attr)) {
            $attr = array('src' => $attr);
        }

        return self::tag('img', $attr + array('alt' => ''), null, array_merge(self::$common_attrib,
            array('src','alt','width','height','border','usemap','onclick','onerror','onload')));
    }
265329
public static function tag($tag, $attr = [], $html = '')
    {
        // Build attributes
        $attributes = [];
        foreach ($attr as $name => $value) {
            $attributes[] = $name.'="'.$value.'"';
        }

        if (in_array($tag, self::$voidElements)) {
            return '<'.$tag.(!empty($attributes) ? ' '.implode(' ', $attributes) : '').'>';
        } else {
            return '<'.$tag.(!empty($attributes) ? ' '.implode(' ', $attributes) : '').'>'.$html.'</'.$tag.'>';
        }
    }
957972
private function _get_session($attr){
    //die(\bbn\x::hdump(self::$sn, $this->session->has(self::$sn), $attr, $this->session->get(self::$sn)));
    if ( $this->session->has(self::$sn) ){
      return $attr ?
        $this->session->get(self::$sn, $attr) :
        $this->session->get(self::$sn);
    }
  }
739782
public function generateRadioField($attr)
    {
        if (empty($attr['name'])) {
            return '';
        }

        $out = '';

        $options = array();
        if (! empty($attr['options'])) {
            $options = $attr['options'];
        }

        if (isset($attr['checked'])) {
            $checkedItem = $attr['checked'];
        }

        unset($attr['options'], $attr['checked']);

        foreach ($options as $value => $label) {
            $id = $attr['id'] . '_' . $value;

            $optionsAttr = array('id' => $id, 'value' => $value);
            if (isset($checkedItem) && $checkedItem == $value) {
                $optionsAttr[] = 'checked';
            }
            $input = $this->Html->tag(
                'input',
                array_merge(
                    $attr,
                    $optionsAttr
                )
            );

            $label = $this->Html->tag(
                'label',
                array('for' => $id),
                $label,
                true
            );

            $out .= $this->Html->tag(
                'div',
                array(
                    'class' => 'radio-item'
                ),
                $input . $label,
                true
            );
        }

        return $out;
    }
1255620
protected static function _buildAttr($attr, $value = '')
    {
        if (\is_string($attr)) {

            if (\is_bool($value)) {
                $value = $value ? 'true' : 'false';
            }

            return "{$attr}=\"{$value}\"";
        }

        if (\is_array($attr)) {
            $attrs = [];

            foreach ($attr as $name => $val) {
                $attrs[] = static::_buildAttr($name, $val);
            }

            return implode(' ', $attrs);
        }

        return '';
    }
1030619
public function addAttributes(array $attr)
    {
        foreach ($attr as $name => $value) {
            $this->setAttribute($name, $value);
        }

        return $this;
    }
450964
protected function initializeProductMediaGallery(array $attr)
    {

        // load the value and the attribute ID
        $value = $attr[MemberNames::VALUE];
        $attributeId = $attr[MemberNames::ATTRIBUTE_ID];

        // query whether the product media gallery entity already exists or not
        if ($entity = $this->loadProductMediaGallery($attributeId, $value)) {
            return $this->mergeEntity($entity, $attr);
        }

        // simply return the attributes
        return $attr;
    }
524368
public static function create($content_model, $content_model_type, $attr)
    {
        $def = new HTMLPurifier_ElementDef();
        $def->content_model = $content_model;
        $def->content_model_type = $content_model_type;
        $def->attr = $attr;
        return $def;
    }
647436
protected function _buildAttribute($attr)
    {
        $string = array();

        foreach ($attr as $key => $value) {
            if (is_array($value)) {
                $value = implode(' ', $value);
            }

            $string[] = $key.'="'.$value.'"';
        }

        return implode(' ', $string);
    }
47814
public function removeElementsAttr($attr) {
		foreach ($this->getElements() as $element) {
			if ($element instanceof Tag) {
				$element->removeAttr($attr);
			}
		}
		
		return $this;
	}
248194
private function checkForTag(string $selector, string $attr, string $type): ?Image {
        $meta = $this->article()->getRawDoc()->find($selector);

        if (!$meta->count()) {
            return null;
        }

        $node = $meta->first();

        if (!($node instanceof Element)) {
            return null;
        }

        if (!$node->hasAttribute($attr) || !$node->attr($attr)) {
            return null;
        }

        $imagePath = $this->buildImagePath($node->attr($attr));
        $mainImage = new Image();
        $mainImage->setImageSrc($imagePath);
        $mainImage->setImageExtractionType($type);
        $mainImage->setConfidenceScore(100);

        $locallyStoredImage = $this->getLocallyStoredImage($mainImage->getImageSrc());

        if (!empty($locallyStoredImage)) {
            $mainImage->setBytes($locallyStoredImage->getBytes());
            $mainImage->setHeight($locallyStoredImage->getHeight());
            $mainImage->setWidth($locallyStoredImage->getWidth());
        }

        return $this->ensureMinimumImageSize($mainImage);
    }
136907
protected function getAttrName($attr)
    {
        $name = strtolower($attr);
        if (array_key_exists($name, $this->_map)) {
            $attr = $this->_map[$name];
        }
        return $attr;
    }
1326157
private function makeAbsoluteAttr($base, \DOMNode $e, $attr)
    {
        if (!$e->attributes->getNamedItem($attr)) {
            return;
        }

        // Trim leading and trailing white space. I don't really like this but
        // unfortunately it does appear on some sites. e.g.  <img src=" /path/to/image.jpg" />
        $url = trim(str_replace('%20', ' ', $e->getAttribute($attr)));
        $url = str_replace(' ', '%20', $url);

        if (!preg_match('!^(https?://|#)!i', $url)) {
            if ($absolute = \SimplePie_IRI::absolutize($base, $url)) {
                $e->setAttribute($attr, $absolute);
            }
        }
    }
161867
public function withUnique(Attribute $attr): self
    {
        $obj = clone $this;
        $obj->_attributes = array_filter($obj->_attributes,
            function (Attribute $a) use ($attr) {
                return $a->oid() != $attr->oid();
            });
        $obj->_attributes[] = $attr;
        return $obj;
    }
1128688
public function attributeWas($attr)
    {
        return $this->attributeChanged($attr) ?
                $this->changedAttributes[$attr] :
                $this->getAttribute($attr);
    }
1354041
public static function parseAttrs($attr)
    {
        /*
         * Skip empty strings
         */
        if (trim($attr) == '') {
            return '';
        }

        /*
         * Match all attribute like parts from string.
         */
        preg_match_all('/[a-zA-Z0-9-_:.]+(\s?=\s?("|\')[^\2]*\2|\s)/U', $attr, $attr);

        /*
         * Get the interessting part.
         */
        $attr = $attr[0];

        $r = array();
        foreach ($attr as $k => $v) {
            /*
             * Skip empty matches
             */
            if (trim($v) == '') {
                continue;
            }

            /*
             * Split by the first = symbol.
             */
            $e = explode('=', $v, 2);
            /*
             * attribute name.
             */
            $at = trim($e[0]);
            /*
             * attribute value.
             */
            $val = isset($e[1]) ? trim($e[1]) : null;

            if ($val !== null) {
                /*
                 * trim the quotation symbols
                 */
                $val = trim($val, substr($val, 0, 1));
            }

            /*
             * store it in the return variable.
             */
            $r[$at] = $val;
        }

        return $r;
    }
587221
public function getAttr($attr)
    {
        $attributeValue = $this->con->evaluateJavascript(sprintf('%s.getAttribute(%s)', $this->getAccessor(), json_encode($attr)));

        if ($attributeValue === false) {
            // see https://github.com/kriswallsmith/Buzz/pull/138 bug
            return '';
        }

        return $attributeValue;
    }