diff options
author | Cash Costello <cash.costello@gmail.com> | 2012-07-13 22:02:22 -0400 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2012-07-13 22:02:22 -0400 |
commit | 695651451b262c526d6aaf9d0988ce557ff50e95 (patch) | |
tree | 92afd91c81f851e78dd87af0e1f6c2f848f5a8b2 /actions/photos | |
parent | a2e4f84be4da51b7ec8fbe625b1b26dde2ad9289 (diff) | |
parent | 67d855d73499f36f15331e1ff18cccd13aa8aa74 (diff) | |
download | elgg-695651451b262c526d6aaf9d0988ce557ff50e95.tar.gz elgg-695651451b262c526d6aaf9d0988ce557ff50e95.tar.bz2 |
Merging admin changes from Brett's repo
Diffstat (limited to 'actions/photos')
-rw-r--r-- | actions/photos/admin/create_thumbnails.php | 70 | ||||
-rw-r--r-- | actions/photos/admin/imtest.php | 18 |
2 files changed, 88 insertions, 0 deletions
diff --git a/actions/photos/admin/create_thumbnails.php b/actions/photos/admin/create_thumbnails.php new file mode 100644 index 000000000..f2e9b26e2 --- /dev/null +++ b/actions/photos/admin/create_thumbnails.php @@ -0,0 +1,70 @@ +<?php +/** + * Tidypics Thumbnail Creation Test + * + * Called through ajax, but registered as an Elgg action. + * + */ + +elgg_load_library('tidypics:resize'); + +$guid = get_input('guid'); +$image = get_entity($guid); + +if (!$image || !($image instanceof TidypicsImage)) { + register_error(elgg_echo('tidypics:thumbnail_tool:unknown_image')); + forward(REFERER); +} + +$filename = $image->getFilename(); +$container_guid = $image->container_guid; +if (!$filename || !$container_guid) { + register_error(elgg_echo('tidypics:thumbnail_tool:invalid_image_info')); + forward(REFERER); +} + +$title = $image->title; +$prefix = "image/$container_guid/"; +$filestorename = substr($filename, strlen($prefix)); + +$image_lib = elgg_get_plugin_setting('image_lib', 'tidypics'); +if (!$image_lib) { + $image_lib = "GD"; +} + +// ImageMagick command line +if ($image_lib == 'ImageMagick') { + if (!tp_create_im_cmdline_thumbnails($image, $prefix, $filestorename)) { + trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick command line', E_USER_WARNING); + register_error(elgg_echo('tidypics:thumbnail_tool:create_failed')); + forward(REFERER); + } + +// imagick PHP extension +} else if ($image_lib == 'ImageMagickPHP') { + if (!tp_create_imagick_thumbnails($image, $prefix, $filestorename)) { + trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick PHP', E_USER_WARNING); + register_error(elgg_echo('tidypics:thumbnail_tool:create_failed')); + forward(REFERER); + } +// gd +} else { + if (!tp_create_gd_thumbnails($image, $prefix, $filestorename)) { + trigger_error('Tidypics warning: failed to create thumbnails - GD', E_USER_WARNING); + register_error(elgg_echo('tidypics:thumbnail_tool:create_failed')); + forward(REFERER); + } +} + +$url = elgg_normalize_url("photos/thumbnail/$guid/large"); +system_message(elgg_echo('tidypics:thumbnail_tool:created')); + +if (elgg_is_xhr()) { + echo json_encode(array( + 'guid' => $guid, + 'title' => $title, + 'thumbnail_src' => $url + )); +} + +forward(REFERER);
\ No newline at end of file diff --git a/actions/photos/admin/imtest.php b/actions/photos/admin/imtest.php new file mode 100644 index 000000000..a58643d0e --- /dev/null +++ b/actions/photos/admin/imtest.php @@ -0,0 +1,18 @@ +<?php +/** + * Tidypics ImageMagick Location Test + * + * Called through ajax. Not a registered Elgg action. + */ + +$location = $_GET['location']; + +$command = $location . "convert -version"; + +$result = system($command, $return_val); + +if ($return_val == 0) { + echo $result; +} else { + echo "Unable to run ImageMagick. Please check the path."; +} |