Skip to content

Commit 5708cc9

Browse files
author
anisa kusumadewi
committed
bug fix: extern pic without heigt/width
1 parent e4cf369 commit 5708cc9

File tree

4 files changed

+28
-29
lines changed

4 files changed

+28
-29
lines changed

action.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,6 @@
642642
$newdata = $templatable->export_for_template($myrenderer);// Viewcontroller takes model's data and arranges it for display.
643643

644644
echo json_encode(['status' => 'success', 'pdfannotatorid' => $documentid, 'newdata' => $newdata]);
645-
646645
}
647646

648647
}

locallib.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function pdfannotator_display_embed($pdfannotator, $cm, $course, $file, $page =
6464
// Load and execute the javascript files.
6565
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/pdf.js?ver=00002"));
6666
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/textclipper.js"));
67-
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/index.js?ver=00034"));
67+
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/index.js?ver=00035"));
6868
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/locallib.js?ver=00005"));
6969

7070
// Pass parameters from PHP to JavaScript.
@@ -227,21 +227,22 @@ function pdfannotator_split_content_image($content, $res, $itemid, $context=null
227227
$data['filepath'] = $tempinfo['filepath'];
228228
$data['filesize'] = $tempinfo['filesize'];
229229
$data['imagestorage'] = 'intern';
230+
preg_match('/height=[0-9]+/', $imgstr, $height);
231+
$data['imageheight'] = str_replace("\"", "", explode('=', $height[0])[1]);
232+
preg_match('/width=[0-9]+/', $imgstr, $width);
233+
$data['imagewidth'] = str_replace("\"", "", explode('=', $width[0])[1]);
230234
} else if (!str_contains($CFG->wwwroot, $url[0])){
231235
$data['imagestorage'] = 'extern';
232236
$data['format'] = $format[0];
237+
$imagemetadata = getimagesize($url[0]);
233238
$data['image'] = 'data:image/' . $format[0] . ";base64," . base64_encode(file_get_contents($url[0]));
234-
// $data['image'] = $url[0];
239+
$data['imagewidth'] = $imagemetadata[0];
240+
$data['imageheight'] = $imagemetadata[1];
235241
} else {
236242
$data['success'] = "error";
237243
$data['message'] = "cannot load image";
238244
}
239245

240-
preg_match('/height=[0-9]+/', $imgstr, $height);
241-
$data['imageheight'] = str_replace("\"", "", explode('=', $height[0])[1]);
242-
preg_match('/width=[0-9]+/', $imgstr, $width);
243-
$data['imagewidth'] = str_replace("\"", "", explode('=', $width[0])[1]);
244-
245246
$res[] = $firststr;
246247
$res[] = $data;
247248
$content = $laststr;

shared/index.js

Lines changed: 19 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
defined('MOODLE_INTERNAL') || die();
2626

2727
$plugin->component = 'mod_pdfannotator';
28-
$plugin->version = 2022110700;
28+
$plugin->version = 2022110900;
2929
$plugin->release = 'PDF Annotator v1.4 release 11';
3030
$plugin->requires = 2021051700;
3131
$plugin->maturity = MATURITY_STABLE;

0 commit comments

Comments
 (0)