All Astronauts Posted February 6, 2018 Posted February 6, 2018 Two small backend additions that will not impact any existing code/apps but would be nice to have added for 4.3 (pretty please with beer on top?) 1) Google Maps render function needs updating. The sensor parameter is no longer needed at all and can be removed. Circa 2014-sometime this was axed. public function render( $width, $height, $zoom=NULL ) to public function render( $width, $height, $zoom=NULL, $scale=1, $maptype='roadmap', etc...) https://developers.google.com/maps/documentation/static-maps/intro#quick_example $scale is needed as static maps api is limited with scale 1 to a maximum of 640x640 pixel images. If we pass $scale = 2 we get the same image but twice the pixels to work with (up to 1280x1280). Both scale 1 and scale 2 are available with the default free plan. $maptype is self explanatory; we could be getting satellite, hybrid, terrain but as is the IPS method is locked down to roadmap. Boo (and not boo-urns) Other vars are available to pass through as well if you are feeling it. $imageUrl = \IPS\Http\Url::external( 'https://maps.googleapis.com/maps/api/staticmap' )->setQueryString( array( 'center' => $location, 'zoom' => $zoom === NULL ? NULL : ceil( $zoom * 8 ), 'size' => "{$width}x{$height}", 'sensor' => 'false', // REMOVE 'scale' => $scale == 1 ? 1 : 2 , // EASY PICKINGS 'maptype' => // INSERT HORRIBLE TERNARY OPERATOR STATEMENT HERE 'markers' => $location, 'key' => \IPS\Settings::i()->google_maps_api_key, ) ); A few minutes of time, more better for us. No impact on current suite apps/plugins. 2) Add uploaded file storage link to the returned json in the upload form helper. I did this manually a few months ago to see that it worked and then forgot about it until now. Basically, you specifically exception out images for preview in the upload form helper on drag/drop/etc. Which is nice. We get preview thumbs. Neat. Other file formats don't get that treatment though. Understandable for the default suite what with needing a new js template to account for such stuff, but as it is, we are blocked from doing so ourselves since the storage url for the uploaded file object isn't kicked back out on the ajax return. This is on the __construct of course, and probably needed on the html() as well \IPS\Output::i()->json( array( 'id' => $insertId, 'key' => $_SERVER['HTTP_X_PLUPLOAD'], 'imagesrc' => $fileObj->isImage() ? (string) $fileObj->url : NULL, 'filesrc' => !($fileObj->isImage()) ? (string) $fileObj->url : NULL, // NEW GENERIC FILE URL 'thumbnail' => ( $fileObj->isImage() AND $fileObj->attachmentThumbnailUrl !== NULL and is_string( $fileObj->attachmentThumbnailUrl ) ) ? \IPS\File::get( $this->options['storageExtension'], $fileObj->attachmentThumbnailUrl )->url : NULL, ) ); With that present we can, if so desire, use it as we will. Uploading audio files? Toss an html5 (or tiny js) player there in the template instead of the default file icon that appears. And so on and so forth... Two cents and all that. Thanks.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.