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

Support img tags in HTML label text #58716

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

nyalldawson
Copy link
Collaborator

@nyalldawson nyalldawson commented Sep 13, 2024

Allows use of img tags in HTML label content. The following logic is applied:

  • Image path is set via the src="xxx" attribute. Local, HTTP, and base64 encoded paths are permitted
  • Any image format readable by QGIS can be used
  • Image sizes can be specified via the width="##" and height="##" attributes. If width or height is not specified it will automatically be calculated from the original image size
  • If width or height are specified, they are considered to be in POINTS
  • The css width/height settings are NOT respected (this is a Qt limitation)
  • Images are not supported for curved text labels
  • Images are placed inline only, floating images are not supported

Sponsored by City of Freiburg im Breisgau

@nyalldawson nyalldawson added Requires Tests! Waiting on the submitter to add unit tests before eligible for merging Labeling Related to QGIS map labeling Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. Changelog Items that are queued to appear in the visual changelog - remove after harvesting labels Sep 13, 2024
@qgis-bot
Copy link
Collaborator

@nyalldawson

This pull request has been tagged for the changelog.

  • The description will be harvested so please provide a "nearly-ready" text for the final changelog
  • If possible, add a nice illustration of the feature. Only the first one in the description will be harvested (GIF accepted as well)
  • If you can, it's better to give credits to your sponsor, see below for different formats.

You can edit the description.

Format available for credits
  • Funded by NAME
  • Funded by URL
  • Funded by NAME URL
  • Sponsored by NAME
  • Sponsored by URL
  • Sponsored by NAME URL

Thank you!

@qgis-bot
Copy link
Collaborator

@nyalldawson
This pull request has been tagged as requiring documentation.

A documentation ticket will be opened at https://github.com/qgis/QGIS-Documentation when this PR is merged.

Please update the description (not the comments) with helpful description and screenshot to help the work from documentors.
Also, any commit having [needs-doc] or [Needs Documentation] in will see its message pushed to the issue, so please be as verbose as you can.

Thank you!

@github-actions github-actions bot added this to the 3.40.0 milestone Sep 13, 2024
Copy link

github-actions bot commented Sep 13, 2024

🪟 Windows builds ready!

Windows builds of this PR are available for testing here. Debug symbols for this build are available here.

(Built from commit ee94f2d)

Adds support for base64 encoded image decoding when the path
is a HTML data URL (in addition to the existing "base64:..."
format support)

Allows use of eg "data:image/jpeg;base64,XXXXXXXX" formats
for image paths, so that the image cache can correctly handle
embedded image paths from HTML/CSS content
Modifies the QgsTextDocument API to extract images from HTML
content, and store in the associated
QgsTextFragment/QgsTextCharacterFormat objects
Allows use of img tags in HTML label content. The following logic
is applied:

- Image path is set via the src="xxx" attribute. Local, HTTP, and
base64 encoded paths are permitted
- Any image format readable by QGIS can be used
- Image sizes can be specified via the width="##" and height="##"
attributes. If width or height is not specified it will automatically
be calculated from the original image size
- If width or height are specified, they are considered to be
in POINTS
- The css width/height settings are NOT respected (this is a Qt
limitation)
- Images are not supported for curved text labels
- Images are placed inline only, floating images are not supported

Sponsored by City of Freiburg im Breisgau
@nyalldawson nyalldawson removed the Requires Tests! Waiting on the submitter to add unit tests before eligible for merging label Sep 17, 2024
@qgis qgis deleted a comment from github-actions bot Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog Items that are queued to appear in the visual changelog - remove after harvesting Freeze Exempt Feature Freeze exemption granted Labeling Related to QGIS map labeling Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants