         cell.accessibilityIdentifier = "photo_cell_\(indexPath.item)"
         cell.settings = settings
         let item = self.items[indexPath.row]
+        cell.imageView.contentMode = .scaleAspectFill
+        cell.imageView.sizeToFit()
         cell.imageView.image = rowHandler(item)
         
         // Set selection number

            cell.photoSelected = true
        }
        
        // Update done button
        self.viewController.navigationItem.rightBarButtonItem?.isEnabled = !self.selections.isEmpty
        
        return false
    }
    
    public func registerCellIdentifiersForCollectionView(_ collectionView: UICollectionView?) {
        collectionView?.register(UINib(nibName: "PhotoCell", bundle: nil), forCellWithReuseIdentifier: photoCellIdentifier)
    }
    
}

//
//

import UIKit
import BSGridCollectionViewLayout

open class CustomPhotoDataSource<T: NSObject>: NSObject, UICollectionViewDataSource, UICollectionViewDelegate {
    
    public var selections = [T]()
    public var items: [T]!
    public var changeSelections: (([T]) -> Void)? = nil
    
    var collectionView: UICollectionView!
    
    var settings: Settings = Settings()
    let rowHandler: ((T) -> UIImage)
    
    fileprivate let photoCellIdentifier = "photoCellIdentifier"
    
    let bundle: Bundle = Bundle(path: Bundle(for: PhotosViewController.self).path(forResource: "BSImagePicker", ofType: "bundle")!)!
    
    public init(_ items: [T], collectionView: UICollectionView!, rowHandler: @escaping ((T) -> UIImage), selections: [T]? = nil) {
        self.items = items
        self.collectionView = collectionView
        self.rowHandler = rowHandler
        if let selections = selections {
            self.selections = selections
        }
        super.init()
        self.collectionView.delegate = self
        self.collectionView.dataSource = self
        self.collectionView.collectionViewLayout = GridCollectionViewLayout()
    }
    
    public func numberOfSections(in collectionView: UICollectionView) -> Int {
