Turn Image gray with grayscaling in line php

The situation is like this. There are designments and some of them are finished so they have ‘0’ days left. So I used the 0 days to make a function that when days are 0 the image would turn grey. Everything works fine except that the image won’t change. but if I do like put some text in the place it will show that text instead of the image so the function works only the gray scaling part isn’t.

[code] function get_all_in_progress_designments($now) {

    $this->db->where('active', 1);
    $this->db->where('deleted !=', '1');

$this->db->order_by(‘date_to’, ‘DESC’);
$designments = $this->db->get(‘designments’)->result_array();
foreach ($designments as $key => &$designment_info) {
$designment_info[‘image’] = self::get_image_for_designment($designment_info[‘designment_id’]);
$designment_info[‘count_joined’] = self::get_users_count_joined_by_id($designment_info[‘designment_id’]);
$designment_info[‘count_ideas’] = self::get_users_count_ideas_by_id($designment_info[‘designment_id’]);
$date_to = $designment_info[‘date_to’];
$diff = $date_to - $now;
$days = round($diff / 86400);
$time_left = $days . ’ days’;

        if($days <= 0){
 $days = 0;
  $image =  self::get_image_for_designment($designment_info['designment_id'], IMG_FILTER_GRAYSCALE);

            
            $time_left = $days . ' days';

        
            
    $designment_info['image'] = $image;    
$designment_info['time_left'] = $time_left;
$des[] = $designments[$key];

}

    }


    return $des;
}[/code]

So the problem is in this line I guess:

$image = self::get_image_for_designment($designment_info['designment_id'], IMG_FILTER_GRAYSCALE);

Can you help me?

You’re over complicating it, just turn it grayscale by adding a CSS class to it.

https://css-tricks.com/almanac/properties/f/filter/

Sponsor our Newsletter | Privacy Policy | Terms of Service