35
36 $imageheader = Query::run("SELECT b.`id` as bericht_id, b.`publicatie_datum`, b.`slug`, b.`titel`, n.`id`, t.`titel` as categorie, t.`slug` as type_slug FROM berichten_nieuws as n LEFT JOIN `berichten` as b ON b.`id` = n.`bericht_id` LEFT JOIN `berichten_nieuws_types` as t ON n.`type_id` = t.`id` WHERE b.`publicatie_datum` <= NOW() ORDER BY b.`publicatie_datum` DESC LIMIT 5")->fetchAll('assoc');
37 foreach ($imageheader as $key => $value) {
38 $imageheader[$key]['image'] = Query::on('berichten_afbeeldingen')->where(['bericht_id', '=', $imageheader[$key]['bericht_id']], ['hoofd_afbeelding', '=', 1])->first('assoc');
39 }
40
41 $randomheader = $imageheader[array_rand($imageheader)];
42 if(empty($randomheader['image'])) {
43 $randomheader = [];
44 }else{
45 $resolutie = getimagesize(Media::root(1)."Nieuws/".$randomheader['image']['bestandsnaam'].'.jpg');
46 if($resolutie[0] < 768){
47 $randomheader = [];
48 }
49 }
50 $team_id = Query::run("SELECT id FROM teams WHERE club_id = 1 AND seizoen_id = ? AND oud_team = 0", [SEIZOEN])->fetch('assoc');
51
52
53 if (!isset($_COOKIE['volg_team'])) {
54 $_COOKIE['volg_team'] = $team_id['id'];