-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathimageresize.php
More file actions
102 lines (89 loc) · 2.89 KB
/
imageresize.php
File metadata and controls
102 lines (89 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
require_once 'imageresize.civix.php';
use CRM_Imageresize_ExtensionUtil as E;
/**
* Implements hook_civicrm_config().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_config
*/
function imageresize_civicrm_config(&$config) {
_imageresize_civix_civicrm_config($config);
}
/**
* Implements hook_civicrm_install().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
*/
function imageresize_civicrm_install() {
_imageresize_civix_civicrm_install();
}
/**
* Implements hook_civicrm_enable().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_enable
*/
function imageresize_civicrm_enable() {
_imageresize_civix_civicrm_enable();
}
// --- Functions below this ship commented out. Uncomment as required. ---
/**
* Implements hook_civicrm_preProcess().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_preProcess
*
// */
/**
* Implements hook_civicrm_navigationMenu().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_navigationMenu
*
function imageresize_civicrm_navigationMenu(&$menu) {
_imageresize_civix_insert_navigation_menu($menu, 'Mailings', array(
'label' => E::ts('New subliminal message'),
'name' => 'mailing_subliminal_message',
'url' => 'civicrm/mailing/subliminal',
'permission' => 'access CiviMail',
'operator' => 'OR',
'separator' => 0,
));
_imageresize_civix_navigationMenu($menu);
} // */
/**
* Implements hook_civicrm_alterMenu().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_alterMenu
*/
function imageresize_civicrm_alterMenu(&$items) {
$items['civicrm/contact/imagefile']['page_callback'] = 'CRM_Imageresize_Page_ImageFile';
$items['civicrm/file']['page_callback'] = 'CRM_Imageresize_Page_File';
}
/**
* Implements hook_civicrm_pageRun().
*
*/
function imageresize_civicrm_pageRun(&$page) {
$class_name = get_class($page);
if ($class_name == 'CRM_Contact_Page_View_Summary') {
$smarty = CRM_Core_Smarty::singleton();
$imageURL = CRM_Utils_Array::value('imageURL', $smarty->_tpl_vars);
if (! $imageURL) {
return;
}
$matches = array();
if (preg_match('/filename\=([^&]*)/', $imageURL, $matches)) {
$path = CRM_Core_Config::singleton()->customFileUploadDir . $matches[1];
$matches = array();
preg_match( '/src="([^"]*)"/i', $imageURL, $matches) ;
if (!empty($matches)) {
$url = $matches['1'];
$urlImg = $matches['1']. '&image_styles=summary';
}
list($imageWidth, $imageHeight) = getimagesize($path);
list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
$url = "<a href=\"$url\" class='crm-image-popup'>
<img src=\"$urlImg\" width=$imageThumbWidth height=$imageThumbHeight/>
</a>";
$smarty->assign("imageURL", $url);
}
}
}