Fix media with no taken On info
This commit is contained in:
@@ -120,11 +120,12 @@ class Media extends PhpObject {
|
||||
else {
|
||||
$asMediaInfo = $this->getMediaInfoFromFile($sMediaName);
|
||||
|
||||
//Converting times to DB Time Zone, by using date()
|
||||
//Converting times to Site Time Zone, by using date()
|
||||
//Media Timezone is kept in a separate field for later conversion to Local Time
|
||||
$asDbInfo = array(
|
||||
Db::getId(Project::PROJ_TABLE) => $this->oProject->getProjectId(),
|
||||
'filename' => $sMediaName,
|
||||
'taken_on' => ($asMediaInfo['taken_ts'] > 0)?date(Db::TIMESTAMP_FORMAT, $asMediaInfo['taken_ts']):'0000-00-00 00:00:00',
|
||||
'taken_on' => date(Db::TIMESTAMP_FORMAT, ($asMediaInfo['taken_ts'] > 0)?$asMediaInfo['taken_ts']:$asMediaInfo['file_ts']),
|
||||
'posted_on' => date(Db::TIMESTAMP_FORMAT, $asMediaInfo['file_ts']),
|
||||
'timezone' => $asMediaInfo['timezone'],
|
||||
'width' => $asMediaInfo['width'],
|
||||
@@ -151,7 +152,6 @@ class Media extends PhpObject {
|
||||
$sMediaPath = self::getMediaPath($sMediaName);
|
||||
$sType = self::getMediaType($sMediaName);
|
||||
|
||||
$iTimeStamp = $iTakenOn = 0;
|
||||
$iPostedOn = filemtime($sMediaPath);
|
||||
$sTimeZone = date_default_timezone_get();
|
||||
$iWidth = 0;
|
||||
@@ -224,16 +224,13 @@ class Media extends PhpObject {
|
||||
|
||||
//Assign the correct Time Zone to $sTakenOn if it is not already contained in it. Then get Unix Timestamp
|
||||
//Time Zone (2nd parameter) will be ignored if already contained in $sTakenOn
|
||||
$iTakenOn = 0;
|
||||
if($sTakenOn != '') {
|
||||
$oTakenOn = new \DateTime($sTakenOn, new \DateTimeZone($sTimeZone));
|
||||
$iTakenOn = $oTakenOn->format('U');
|
||||
}
|
||||
|
||||
//Merge timestamps
|
||||
$iTimeStamp = ($iTakenOn > 0)?$iTakenOn:$iPostedOn;
|
||||
|
||||
return array(
|
||||
'timestamp' => $iTimeStamp,
|
||||
'timezone' => $sTimeZone,
|
||||
'taken_ts' => $iTakenOn,
|
||||
'file_ts' => $iPostedOn,
|
||||
|
||||
Reference in New Issue
Block a user