mirror of
https://github.com/inventree/inventree-docs.git
synced 2025-09-13 22:21:33 +00:00
Extend report documentation (#318)
* Small updates for reporting docs * Fix navbar * Add "media" link in navbar * Extend documentation for reporting features and tags
This commit is contained in:
@@ -2,9 +2,13 @@
|
||||
title: Using media files
|
||||
---
|
||||
|
||||
## Images
|
||||
## Media Files
|
||||
|
||||
To load images into the reports/labels the report helper must be loaded in the template.
|
||||
*Media files* are any files uploaded to the InvenTree server by the user. These are stored under the `/media/` directory and can be accessed for use in custom reports or labels.
|
||||
|
||||
**Load Report Functions**
|
||||
|
||||
To load images into the reports/labels the report helper functions must first be loaded in the template:
|
||||
|
||||
```html
|
||||
{% raw %}
|
||||
@@ -13,9 +17,79 @@ To load images into the reports/labels the report helper must be loaded in the t
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
### Assets
|
||||
### Uploaded Images
|
||||
|
||||
You can add images to the reports and labels by using the asset template tag:
|
||||
You can access an uploaded image file if you know the *path* of the image, relative to the top-level `/media/` directory. To load the image into a report, use the `{% raw %}{% uploaded_image ... %}{% endraw %}` tag:
|
||||
|
||||
```html
|
||||
{% raw %}
|
||||
<!-- Load the report helper functions -->
|
||||
{% load report %}
|
||||
<img src='{% uploaded_image "subdir/my_image.png" %}'/>
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
!!! info "Missing Image"
|
||||
If the supplied image filename does not exist, it will be replaced with a placeholder image file
|
||||
|
||||
!!! warning "Invalid Image"
|
||||
If the supplied file is not a valid image, it will be replaced with a placeholder image file
|
||||
|
||||
### Part images
|
||||
|
||||
A shortcut function is provided for rendering an image associated with a Part instance. You can render the image of the part using the `{% raw %}{% part_image ... %}{% endraw %}` template tag:
|
||||
|
||||
```html
|
||||
{% raw %}
|
||||
<!-- Load the report helper functions -->
|
||||
{% load report %}
|
||||
<img src='{% part_image part %}'/>
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
### Company Images
|
||||
|
||||
A shortcut function is provided for rendering an image associated with a Company instance. You can render the image of the company using the `{% raw %}{% company_image ... %}{% endraw %}` template tag:
|
||||
|
||||
```html
|
||||
{% raw %}
|
||||
<!-- Load the report helper functions -->
|
||||
{% load report %}
|
||||
<img src='{% company_image company %}'/>
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## InvenTree Logo
|
||||
|
||||
A template tag is provided to load the InvenTree logo image into a report. You can render the logo using the `{% raw %}{% logo_image %}{% endraw %}` tag:
|
||||
|
||||
```html
|
||||
{% raw %}
|
||||
{% load report %}
|
||||
<img src='{% logo_image %}'/>
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
### Custom Logo
|
||||
|
||||
If the system administrator has enabled a [custom logo](../start/config.md#customisation-options), then this logo will be used instead of the base InvenTree logo.
|
||||
|
||||
This is a useful way to get a custom company logo into your reports.
|
||||
|
||||
If you have a custom logo, but explicitly wish to load the InvenTree logo itself, add `custom=False` to the tag:
|
||||
|
||||
```html
|
||||
{% raw %}
|
||||
{% load report %}
|
||||
<img src='{% logo_image custom=False %}'/>
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## Report Assets
|
||||
|
||||
[Report Assets](./report.md#report-assets) are files specifically uploaded by the user for inclusion in generated reports and labels.
|
||||
|
||||
You can add asset images to the reports and labels by using the `{% raw %}{% asset ... %}{% endraw %}` template tag:
|
||||
|
||||
```html
|
||||
{% raw %}
|
||||
@@ -25,17 +99,3 @@ You can add images to the reports and labels by using the asset template tag:
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
!!! info "Assets location"
|
||||
You need to place your asset images to the report/assets directory in the [data directory](../start/docker_dev.md/#data-directory)
|
||||
|
||||
### Part images
|
||||
|
||||
You can render the images of the parts using the part_image template tag:
|
||||
|
||||
```html
|
||||
{% raw %}
|
||||
<!-- Load the report helper functions -->
|
||||
{% load report %}
|
||||
<img src='{% part_image part %}'/>
|
||||
{% endraw %}
|
||||
```
|
||||
|
Reference in New Issue
Block a user