mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-12 10:05:39 +00:00
Report image rendering fix (#5907)
* Allow different image variations to be rendered in when using a part image in a report * Use preview image in default test report * Fix api_version - Missed in https://github.com/inventree/InvenTree/pull/5906 * Update docstring * Add similar functionality for company_image tag * Update report documentation * base-64 encode images for rendering in reports - Allows image manipulation operations to be performed on the images - Avoids any file pathing issues * Update docs * Fix unit tests * More unit test fixes * More unit test * Handle missing file * Instrument unit test - Trying to determine what is going on here * Fix for image resize * Translate error messages * Update default report templates - Specify image size
This commit is contained in:
@ -138,7 +138,7 @@ You can access an uploaded image file if you know the *path* of the image, relat
|
||||
{% raw %}
|
||||
<!-- Load the report helper functions -->
|
||||
{% load report %}
|
||||
<img src='{% uploaded_image "subdir/my_image.png" %}'/>
|
||||
<img src='{% uploaded_image "subdir/my_image.png" width=480 rotate=45 %}'/>
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
@ -148,6 +148,16 @@ You can access an uploaded image file if you know the *path* of the image, relat
|
||||
!!! warning "Invalid Image"
|
||||
If the supplied file is not a valid image, it will be replaced with a placeholder image file
|
||||
|
||||
#### Image Manipulation
|
||||
|
||||
The `{% raw %}{% uploaded_image %}{% endraw %}` tag supports some optional parameters for image manipulation. These can be used to adjust or resize the image - to reduce the size of the generated report file, for example.
|
||||
|
||||
```html
|
||||
{% raw %}
|
||||
{% load report %}
|
||||
<img src='{% uploaded_image "image_file.png" width=500 rotate=45 %}'>
|
||||
{% endraw %}```
|
||||
|
||||
|
||||
### SVG Images
|
||||
|
||||
@ -173,6 +183,26 @@ A shortcut function is provided for rendering an image associated with a Part in
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
#### Image Arguments
|
||||
|
||||
Any optional arguments which can be used in the [uploaded_image tag](#uploaded-images) can be used here too.
|
||||
|
||||
#### Image Variations
|
||||
|
||||
The *Part* model supports *preview* (256 x 256) and *thumbnail* (128 x 128) versions of the uploaded image. These variations can be used in the generated reports (e.g. to reduce generated file size):
|
||||
|
||||
```html
|
||||
{% raw %}
|
||||
{% load report %}
|
||||
<!-- Render the "preview" image variation -->
|
||||
<img src='{% part_image part preview=True %}'>
|
||||
|
||||
<!-- Render the "thumbnail" image variation -->
|
||||
<img src='{% part_image part thumbnail=True %}'>
|
||||
{% 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:
|
||||
@ -185,6 +215,10 @@ A shortcut function is provided for rendering an image associated with a Company
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
#### Image Variations
|
||||
|
||||
*Preview* and *thumbnail* image variations can be rendered for the `company_image` tag, in a similar manner to [part image variations](#image-variations)
|
||||
|
||||
## 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:
|
||||
|
Reference in New Issue
Block a user