src/MediaTrait.php
private function getWeight() {
    if (!is_null($this->options->weight)) {
      return $this->options->weight;
    }

    if (!is_null($this->media)) {
      return $this->media->weight;
    }

    return $this->media()->where('group', $this->group)->count();
  }
private function getWeight() {
    if (!is_null($this->options->weight)) {
      return $this->options->weight;
    }

    if (!is_null($this->media)) {
      return $this->media->weight;
    }

    return $this->media()->where('group', $this->group)->count();
  }
Calculate the weight of the image from options, then from existing media,
then compared to others in the group

@return int
The weight of the image