Cakephp 3 - Get only the first result from hasMany


Hello, I have two models: Products and Images. A product hasMany images. How can I get only the first image of each product?
My current query is:
$products = $this->Products->find()->contain(['Images'])->where(['Products.published =' => 1])->all();

$products = $this->Products->find('all')
    'Images' => function ($q) {
        return $q->first();
->where(['Products.published' => 1]);

other solution:
create a flag in the images to set for example main image that represents the product and filter in where