示例#1
0
/**
 * Image Helper - Prep Image
 * @param $tag
 * @return array
 */
function themify_prep_image($tag)
{
    preg_match_all('/(alt|title|src|class)=("[^"]*")/i', $tag, $image);
    foreach ($image[0] as $attr) {
        parse_str($attr, $tempAttr);
        foreach ($tempAttr as $key => $val) {
            $tempArray[$key] = str_replace(array('"', "'"), array('', ''), $val);
        }
    }
    $image = isset($tempArray) ? $tempArray : array('src' => '', 'alt' => '', 'title' => '');
    if (strpos($image['src'], 'youtube.com') || strpos($image['src'], 'vimeo.com')) {
        $image['src'] = themify_video_image($image['src']);
    }
    return array('src' => trim($image['src'], "\\"), 'alt' => $image['alt'], 'title' => isset($image['title']) ? $image['title'] : '');
}
示例#2
0
/**
 * Image Helper - Prep Image
 * @param $tag
 * @return array
 */
function themify_prep_image($tag)
{
    preg_match_all('/(alt|title|src|class)=("[^"]*")/i', $tag, $image);
    foreach ($image[0] as $attr) {
        parse_str($attr, $tempAttr);
        foreach ($tempAttr as $key => $val) {
            $tempArray[$key] = str_replace(array('"', "'"), array('', ''), $val);
        }
    }
    $image = $tempArray;
    if (strpos($image['src'], "youtube.com") || strpos($image['src'], "vimeo.com")) {
        $image['src'] = themify_video_image($image['src']);
    }
    return array("src" => trim($image['src'], "\\"), "alt" => $image['alt'], "title" => $image['title']);
}