Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added auto width and height dimensions parameters #8314

Merged
merged 1 commit into from Mar 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions doc/Extensions/Dashboards.md
Expand Up @@ -67,3 +67,12 @@ In the dashboard, you want to create an interface graph select the widget called
* Note: you can map the port by description or the alias or by port id. You will need to know this in order to map the port to the graph.

![port-bits-graph](/img/port-bits-port.png)

### Dimension parameter replacement for Generic-image widget

When using the Generic-image widget you can provide the width and height of the widget with your request.
This will ensure that the image will fit nicely with the dimensions if the Generic-image widget.
You can add @AUTO_HEIGHT@ and @AUTO_WIDTH@ to the Image URL as parameters.
Examples:
+ http://librenms.example.com/graph.php?id=333%2C444&type=multiport_bits_separate&legend=no&absolute=1&from=-14200&width=@AUTO_WIDTH@&height=@AUTO_HEIGHT@
+ http://example.com/myimage.php?size=@AUTO_WIDTH@x@AUTO_HEIGHT@
6 changes: 6 additions & 0 deletions html/includes/common/generic-image.inc.php
Expand Up @@ -57,6 +57,12 @@
</form>';
} else {
$widget_settings['title'] = $widget_settings['image_title'];
if (strstr($widget_settings['image_url'], '@AUTO_HEIGHT@')) {
$widget_settings['image_url'] = str_replace('@AUTO_HEIGHT@', $widget_dimensions['y'], $widget_settings['image_url']);
}
if (strstr($widget_settings['image_url'], '@AUTO_WIDTH@')) {
$widget_settings['image_url'] = str_replace('@AUTO_WIDTH@', $widget_dimensions['x'], $widget_settings['image_url']);
}
if (strstr($widget_settings['image_url'], '?')) {
$widget_settings['image_url'] .= "&".mt_rand();
} else {
Expand Down