<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
class Core_View_Helper_ItemBackgroundPhoto extends Core_View_Helper_ItemPhoto
{
    protected $_classPrefix = 'bg_';
    protected $_backgroundClass = 'bg_item_photo';

    public function itemBackgroundPhoto($item, $type = 'thumb.profile', $alt = "", $attribs = array())
    {
        $tag = 'span';
        if (!empty($attribs['tag'])) {
            $tag = $attribs['tag'];
            unset($attribs['tag']);
        }

        $this->setAttributes($item, $type, $attribs, 'bgphoto');
        if ($alt && empty($this->_attribs['title'])) {
            $this->_attribs['title'] = strip_tags($alt);
        }

        if (!empty($this->_attribs['style']) && is_string($this->_attribs['style'])) {
            $this->_attribs['style'][] = $this->_attribs['style'];
        }

        if (!empty($this->_url)) {
            $this->_attribs['style'][] = 'background-image:url("' . $this->_url . '");';
        }
        
        $this->_attribs['class'] = $this->_backgroundClass . ' ' . $this->_attribs['class'];
        return '<' . $tag
        . $this->_htmlAttribs($this->_attribs)
        . '>'
        . '</'
        . $tag
        . '>';
    }
}
