Microweber\Providers\MediaManager::get_picture PHP Метод

get_picture() публичный Метод

public get_picture ( $content_id, $for = 'content', $full = false )
    public function get_picture($content_id, $for = 'content', $full = false)
    {
        $arr = array();
        if ($for == 'post' or $for == 'posts' or $for == 'page' or $for == 'pages') {
            $for = 'content';
        } elseif ($for == 'category' or $for == 'categories') {
            $for = 'categories';
        }
        $arr['rel_type'] = $for;
        $arr['limit'] = '1';
        $arr['rel_id'] = $content_id;
        $imgages = $this->get($arr);
        if ($imgages != false and isset($imgages[0])) {
            if (isset($imgages[0]['filename']) and $full == false) {
                $surl = $this->app->url_manager->site();
                $img = $this->app->format->replace_once('{SITE_URL}', $surl, $imgages[0]['filename']);
                return $img;
            } else {
                return $imgages[0];
            }
        } else {
            if ($for == 'content') {
                $cont_id = $this->app->content_manager->get_by_id($content_id);
                if (isset($cont_id['content'])) {
                    $img = $this->get_first_image_from_html(html_entity_decode($cont_id['content']));
                    if ($img != false) {
                        $surl = $this->app->url_manager->site();
                        $img = $this->app->format->replace_once('{SITE_URL}', $surl, $img);
                        $media_url = media_base_url();
                        if (stristr($img, $surl)) {
                            return $img;
                        } else {
                            return $img;
                            return false;
                        }
                    }
                }
            }
        }
        return false;
    }