Skip to content

Commit

Permalink
bug fix: extern pic without heigt/width
Browse files Browse the repository at this point in the history
  • Loading branch information
anisa kusumadewi committed Nov 9, 2022
1 parent e4cf369 commit 5708cc9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 29 deletions.
1 change: 0 additions & 1 deletion action.php
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,6 @@
$newdata = $templatable->export_for_template($myrenderer);// Viewcontroller takes model's data and arranges it for display.

echo json_encode(['status' => 'success', 'pdfannotatorid' => $documentid, 'newdata' => $newdata]);

}

}
15 changes: 8 additions & 7 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function pdfannotator_display_embed($pdfannotator, $cm, $course, $file, $page =
// Load and execute the javascript files.
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/pdf.js?ver=00002"));
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/textclipper.js"));
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/index.js?ver=00034"));
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/index.js?ver=00035"));
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/locallib.js?ver=00005"));

// Pass parameters from PHP to JavaScript.
Expand Down Expand Up @@ -227,21 +227,22 @@ function pdfannotator_split_content_image($content, $res, $itemid, $context=null
$data['filepath'] = $tempinfo['filepath'];
$data['filesize'] = $tempinfo['filesize'];
$data['imagestorage'] = 'intern';
preg_match('/height=[0-9]+/', $imgstr, $height);
$data['imageheight'] = str_replace("\"", "", explode('=', $height[0])[1]);
preg_match('/width=[0-9]+/', $imgstr, $width);
$data['imagewidth'] = str_replace("\"", "", explode('=', $width[0])[1]);
} else if (!str_contains($CFG->wwwroot, $url[0])){
$data['imagestorage'] = 'extern';
$data['format'] = $format[0];
$imagemetadata = getimagesize($url[0]);
$data['image'] = 'data:image/' . $format[0] . ";base64," . base64_encode(file_get_contents($url[0]));
// $data['image'] = $url[0];
$data['imagewidth'] = $imagemetadata[0];
$data['imageheight'] = $imagemetadata[1];
} else {
$data['success'] = "error";
$data['message'] = "cannot load image";
}

preg_match('/height=[0-9]+/', $imgstr, $height);
$data['imageheight'] = str_replace("\"", "", explode('=', $height[0])[1]);
preg_match('/width=[0-9]+/', $imgstr, $width);
$data['imagewidth'] = str_replace("\"", "", explode('=', $width[0])[1]);

$res[] = $firststr;
$res[] = $data;
$content = $laststr;
Expand Down
39 changes: 19 additions & 20 deletions shared/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'mod_pdfannotator';
$plugin->version = 2022110700;
$plugin->version = 2022110900;
$plugin->release = 'PDF Annotator v1.4 release 11';
$plugin->requires = 2021051700;
$plugin->maturity = MATURITY_STABLE;

0 comments on commit 5708cc9

Please sign in to comment.