# MyLocations: p253 Aspect Fill thumbnails \[SOLVED\]

**URL:** <https://forums.kodeco.com/t/mylocations-p253-aspect-fill-thumbnails-solved/21567>\
**Category:** iOS Apprentice\
**Created:** [October 23, 2016, 12:11am UTC](https://forums.kodeco.com/t/mylocations-p253-aspect-fill-thumbnails-solved/21567 "2016-10-23T00:11:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kickinbahk](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/kickinbahk/32/50350_2.png) [@kickinbahk](https://forums.kodeco.com/u/kickinbahk)\
**Post date:** [October 23, 2016, 12:11am UTC](https://forums.kodeco.com/t/mylocations-p253-aspect-fill-thumbnails-solved/21567/1 "2016-10-23T00:11:29Z")

</div>

Continuing the discussion from [MyLocations: p.253 exercise aspect fill thumbnails [SOLVED]](https://forums.kodeco.com/t/mylocations-p-253-exercise-aspect-fill-thumbnails-solved/14041):

I took a bit of a different approach than the one by @linc.

After a bit of research, the `UIImageView` has a property on it called `.contentMode`. You can set this in `LocationCell`, just above where you set the image property on `photoImageView`.

I added the following code:

```auto
    photoImageView.contentMode = .scaleAspectFill

```

The problem with this is that the images will extend outside the bounds of the container. In @linc 's follow up to his post, he uses `.clipsToBounds` on the UIImageView property to solve the same issue he was having. So I used that method to do the same called from `LocationCell`.

The final additions looked as follows:

```auto
   func configure(for location: Location) {
    ...
    photoImageView.contentMode = .scaleAspectFill
    photoImageView.clipsToBounds = true
    photoImageView.image = thumbnail(for: location)
  }

```

---

<div class="post-metadata">

**Author:** ![anatoliy](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/anatoliy/32/73603_2.png) [@anatoliy](https://forums.kodeco.com/u/anatoliy)\
**Post date:** [November 22, 2017, 8:47pm UTC](https://forums.kodeco.com/t/mylocations-p253-aspect-fill-thumbnails-solved/21567/2 "2017-11-22T20:47:09Z")

</div>

This is good solution, here’s mine:

> [@MyLocations: p253 (243) Aspect Fill thumbnails \[SOLVED\] - Elegant Solution](https://forums.kodeco.com/t/mylocations-p253-243-aspect-fill-thumbnails-solved-elegant-solution/36828):
>
> Continuing former discussions about changing the resizing rule of the thumbnail to Aspect Fill [https://forums.kodeco.com/t/mylocations-p253-aspect-fill-thumbnails-solved/21567?u=anatoliy](https://forums.kodeco.com/t/mylocations-p253-aspect-fill-thumbnails-solved/21567)[https://forums.kodeco.com/t/mylocations-p-253-exercise-aspect-fill-thumbnails-solved/14041?u=anatoliy](https://forums.kodeco.com/t/mylocations-p-253-exercise-aspect-fill-thumbnails-solved/14041) There’s very elegant solution with only 4 lines changed inside the method: func resizedImage(withBounds bounds: CGSize) -\> UIImage { ... let ratio = max(horizontalRatio, verticalRatio) //Change the r…
