Project

General

Profile

« Previous | Next » 

Revision 275b2642

Added by Andreas Kohlbecker over 7 years ago

fix #5948 supressing media when uri is missing, also turning theme function into plain markup function

View differences:

modules/cdm_dataportal/cdm_api/cdm_api.module
469 469
}
470 470

  
471 471
/**
472
 * @todo Improve the documentation of this function.
473
 *
474
 * media Array [4]
475
 * representations Array [3]
476
 * mimeType image/jpeg
477
 * representationParts Array [1]
478
 * duration 0
479
 * heigth 0
480
 * size 0
481
 * uri
482
 * http://wp5.e-taxonomy.eu/dataportal/cichorieae/media/protolog/jpeg/Acanthocephalus_p1.jpg
483
 * uuid 15c687f1-f79d-4b79-992f-7ba0f55e610b
484
 * width 0
485
 * suffix jpg
486
 * uuid 930b7d51-e7b6-4350-b21e-8124b14fe29b
487
 * title
488
 * uuid 17e514f1-7a8e-4daa-87ea-8f13f8742cf9
489 472
 *
490 473
 * @param object $media
491 474
 * @param array $mimeTypes
......
519 502
        $mimeTypes = array();
520 503
        $dwa = 0;
521 504
        $dw = 0;
505
        $valid_parts_cnt = 0;
522 506
        // Look for part with the best matching size.
523 507
        foreach ($representation->parts as $part) {
508
          if(empty($part->uri)){
509
            // skip part if URI is missing
510
            continue;
511
          }
512
          $valid_parts_cnt++;
524 513
          if (isset($part->width) && isset($part->height)) {
525 514
            $dw = $part->width * $part->height - $height * $width;
526 515
          }
......
529 518
          }
530 519
          $dwa += $dw;
531 520
        }
532
        $dwa = (count($representation->parts) > 0) ? $dwa / count($representation->parts) : 0;
533
        $prefRepr[$dwa . '_'] = $representation;
521
        if($valid_parts_cnt > 0){
522
          $dwa = $dwa / $valid_parts_cnt;
523
          $prefRepr[$dwa . '_'] = $representation;
524
        }
534 525
      }
535 526
    }
536 527
  }

Also available in: Unified diff