0

I'm uploading multiple images for a property and everything works well. The images and their conversions are uploaded successfully. However, a conversion is created for every image of a given property but I'd like to create a conversion only for the first image of the multiple uploads. How can I achieve that?

My controller logic

 foreach ($request->file('images') as $image) {
      $property->addMedia($image)->withResponsiveImages()->toMediaCollection();
    }

My model conversion logic

  public function registerMediaConversions(Media $media = null): void
  {
    $this->addMediaConversion('small_thumb')
      ->width(300)
      ->height(200);
  }
Alphy Gacheru
  • 489
  • 1
  • 9
  • 28
  • `foreach ($request->file('images') as $k => $image) { if ($k === 0) { // stuff with conversions } else { // stuff without conversions } }` ? – Don't Panic Jun 20 '23 at 12:19
  • What do you mean by stuff without conversions? Could you please elaborate on that with code if possible? – Alphy Gacheru Jun 20 '23 at 14:02

0 Answers0