Skip to content

Commit

Permalink
Support for media on iNaturalist.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnvanbreda committed Apr 19, 2018
1 parent f1f669d commit 7bf0cc5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions prebuilt_forms/record_details_2.php
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,11 @@ private static function commonControlPhotos($auth, $args, $options, $settings) {
$r .= "<li class=\"gallery-item\"><audio controls " .
"src=\"$imageFolder$medium[path]\" type=\"audio/mpeg\"/></li>";
}
elseif ($medium['media_type'] === 'Image:iNaturalist') {
$imgLarge = str_replace('/thumb.', '/large.', $medium['path']);
$r .= "<li class=\"gallery-item\"><a href=\"$imgLarge\" class=\"fancybox single\">" .
"<img src=\"$medium[path]\" /></a><br/>$medium[caption]</li>";;
}
else {
$r .= "<li class=\"gallery-item\"><a href=\"$imageFolder$medium[path]\" class=\"fancybox single\">" .
"<img src=\"$imageFolder$options[imageSize]-$medium[path]\" /></a><br/>$medium[caption]</li>";
Expand Down
6 changes: 5 additions & 1 deletion prebuilt_forms/verification_5.php
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,11 @@ private static function getMediaHtml($media) {
$path = data_entry_helper::get_uploaded_image_folder();
$r .= '<ul class="gallery">';
foreach ($media as $file) {
if (preg_match('/^http(s)?:\/\/(www\.)?([a-z+(\.kr)]+)/', $file['path'], $matches)) {
if (preg_match('/^https:\/\/static\.inaturalist\.org/', $file['path'])) {
$imgLarge = str_replace('/square.', '/large.', $file['path']);
$media = "<a href=\"$imgLarge\" class=\"inaturalist fancybox\"><img src=\"$file[path]\" /></a>";
}
elseif (preg_match('/^http(s)?:\/\/(www\.)?([a-z+(\.kr)]+)/', $file['path'], $matches)) {
$class = str_replace('.', '', $matches[3]);
$media = "<a href=\"$file[path]\" class=\"social-icon $class\"></a>";
}
Expand Down
6 changes: 5 additions & 1 deletion report_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,11 @@ public static function report_grid($options) {
$imgclass=count($imgs)>1 ? 'multi' : 'single';
$group=count($imgs)>1 && !empty($options['rowId']) ? ' rel="group-' . $row[$options['rowId']] . '"' : '';
foreach($imgs as $img) {
if (preg_match('/^http(s)?:\/\/(www\.)?(?P<site>[a-z]+(\.kr)?)/', $img, $matches)) {
if (preg_match('/^https:\/\/static\.inaturalist\.org/', $img)) {
$imgLarge = str_replace('/square.', '/large.', $img);
$value .= "<a href=\"$imgLarge\" class=\"inaturalist fancybox $imgclass$group\"><img src=\"$img\" /></a>";
}
elseif (preg_match('/^http(s)?:\/\/(www\.)?(?P<site>[a-z]+(\.kr)?)/', $img, $matches)) {
// http, means an external file
// Flickr URLs sometimes have . in them.
$matches['site'] = str_replace('.', '', $matches['site']);
Expand Down

0 comments on commit 7bf0cc5

Please sign in to comment.