Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding the media_type
  • Loading branch information
pmPaulis committed Jun 13, 2024
commit f630a4eee998c25dc1cd5d40ad7defeed26f58d0
12 changes: 8 additions & 4 deletions ProcessMaker/Models/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ public function getManagerUrlAttribute()
* @param Process $process
* @param array $properties
* @param string $key
* @param string $subtype
* @param string $mediaType
*
* @return void
*/
public function saveProcessMedia(Process $process, $properties, $key = 'uuid', $subtype = 'launchpad')
public function saveProcessMedia(Process $process, $properties, $key = 'uuid', $mediaType = 'launchpad')
{
// Validate if the image smaller than 2MB
$maxFileSize = 2 * 1024 * 1024;
Expand All @@ -215,13 +215,17 @@ public function saveProcessMedia(Process $process, $properties, $key = 'uuid', $
return;
}
// Get collection name to save
$collectionName = self::determineCollectionName($process, $subtype);
$collectionName = self::determineCollectionName($process, $mediaType);
// Check if exist
$exist = $process->media()->where($key, $properties[$key])->exists();
if (!$exist) {
// Store the images related move to MEDIA
$process->addMediaFromBase64($properties['url'])
->withCustomProperties(['type' => $properties['type']])
->withCustomProperties([
'media_type' => $mediaType,
'type' => $properties['type'],
'id' => $properties['node_identifier'],
])
->toMediaCollection($collectionName);
}
}
Expand Down