function _vsf_wysiwyg_parse in Visual select file 7
Parses HTML for referenced images, probably added by VSF. Count and group by fid.
2 calls to _vsf_wysiwyg_parse()
- vsf_wysiwyg_element_parse_images in submodules/
vsf_wysiwyg/ vsf_wysiwyg.module - Element 'validator' for all VSF WYSIWYG elements.
- vsf_wysiwyg_field_attach_presave in submodules/
vsf_wysiwyg/ vsf_wysiwyg.module - Implements hook_field_attach_presave().
File
- submodules/
vsf_wysiwyg/ vsf_wysiwyg.module, line 144
Code
function _vsf_wysiwyg_parse(&$fids, $html) {
$fid_map =& drupal_static(__FUNCTION__, array());
$path = base_path() . variable_get('file_public_path', conf_path() . '/files') . '/';
$regex = '#(href|src)="' . $path . '([^"]+)"#';
if (preg_match_all($regex, $html, $matches)) {
foreach ($matches[2] as $path) {
$uri = $path;
if (preg_match('#^styles/([\\w\\-]+)/public/(.+)$#', $path, $match)) {
$uri = $match[2];
}
$uri = 'public://' . $uri;
if (!isset($fid_map[$uri])) {
$fid_map[$uri] = (int) db_query('SELECT fid FROM {file_managed} WHERE uri = :uri', array(
':uri' => $uri,
))
->fetchField();
}
@$fids[$fid_map[$uri]]++;
}
}
}