Syntax Syntax
Parameters Parameters
- $ThisFileInfo
-
(Required)
Return Return
(bool)
Source Source
File: wp-includes/ID3/getid3.lib.php
/** * @param array $ThisFileInfo * @param bool $option_tags_html default true (just as in the main getID3 class) * * @return bool */ public static function CopyTagsToComments(&$ThisFileInfo, $option_tags_html=true) { // Copy all entries from ['tags'] into common ['comments'] if (!empty($ThisFileInfo['tags'])) { if (isset($ThisFileInfo['tags']['id3v1'])) { // bubble ID3v1 to the end, if present to aid in detecting bad ID3v1 encodings $ID3v1 = $ThisFileInfo['tags']['id3v1']; unset($ThisFileInfo['tags']['id3v1']); $ThisFileInfo['tags']['id3v1'] = $ID3v1; unset($ID3v1); } foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) { foreach ($tagarray as $tagname => $tagdata) { foreach ($tagdata as $key => $value) { if (!empty($value)) { if (empty($ThisFileInfo['comments'][$tagname])) { // fall through and append value } elseif ($tagtype == 'id3v1') { $newvaluelength = strlen(trim($value)); foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) { $oldvaluelength = strlen(trim($existingvalue)); if (($newvaluelength <= $oldvaluelength) && (substr($existingvalue, 0, $newvaluelength) == trim($value))) { // new value is identical but shorter-than (or equal-length to) one already in comments - skip break 2; } } if (function_exists('mb_convert_encoding')) { if (trim($value) == trim(substr(mb_convert_encoding($existingvalue, $ThisFileInfo['id3v1']['encoding'], $ThisFileInfo['encoding']), 0, 30))) { // value stored in ID3v1 appears to be probably the multibyte value transliterated (badly) into ISO-8859-1 in ID3v1. // As an example, Foobar2000 will do this if you tag a file with Chinese or Arabic or Cyrillic or something that doesn't fit into ISO-8859-1 the ID3v1 will consist of mostly "?" characters, one per multibyte unrepresentable character break 2; } } } elseif (!is_array($value)) { $newvaluelength = strlen(trim($value)); foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) { $oldvaluelength = strlen(trim($existingvalue)); if ((strlen($existingvalue) > 10) && ($newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) { $ThisFileInfo['comments'][$tagname][$existingkey] = trim($value); break; } } } if (is_array($value) || empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) { $value = (is_string($value) ? trim($value) : $value); if (!is_int($key) && !ctype_digit($key)) { $ThisFileInfo['comments'][$tagname][$key] = $value; } else { if (!isset($ThisFileInfo['comments'][$tagname])) { $ThisFileInfo['comments'][$tagname] = array($value); } else { $ThisFileInfo['comments'][$tagname][] = $value; } } } } } } } // attempt to standardize spelling of returned keys $StandardizeFieldNames = array( 'tracknumber' => 'track_number', 'track' => 'track_number', ); foreach ($StandardizeFieldNames as $badkey => $goodkey) { if (array_key_exists($badkey, $ThisFileInfo['comments']) && !array_key_exists($goodkey, $ThisFileInfo['comments'])) { $ThisFileInfo['comments'][$goodkey] = $ThisFileInfo['comments'][$badkey]; unset($ThisFileInfo['comments'][$badkey]); } } if ($option_tags_html) { // Copy ['comments'] to ['comments_html'] if (!empty($ThisFileInfo['comments'])) {