Skip to content

Commit

Permalink
add case
Browse files Browse the repository at this point in the history
  • Loading branch information
nivv committed Oct 16, 2024
1 parent 9397202 commit bf70636
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/ContentGetters/ImageGetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Ikoncept\Fabriq\ContentGetters;

use Exception;
use Ikoncept\Fabriq\Fabriq;
use Ikoncept\Fabriq\Models\Image;
use Infab\TranslatableRevisions\Models\RevisionMeta;
Expand All @@ -23,9 +24,15 @@ public static function get(RevisionMeta $meta, bool $publishing = false)
return null;
}

$keyName = Fabriq::getModelClass('image')->getKeyName();
try {
$keyName = Fabriq::getModelClass('image')->getKeyName();
$id = $meta->meta_value[$keyName];
} catch (Exception $e) {
$id = $meta->meta_value[0];
}

$image = Fabriq::getModelClass('image')
->where('id', $meta->meta_value[$keyName])
->where('id', $id)
->first();

if (! $image) {
Expand Down

0 comments on commit bf70636

Please sign in to comment.