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

Encode SVGs on server #88

Open
dChiamp opened this issue Feb 7, 2025 · 0 comments · May be fixed by #89
Open

Encode SVGs on server #88

dChiamp opened this issue Feb 7, 2025 · 0 comments · May be fixed by #89
Assignees

Comments

@dChiamp
Copy link
Contributor

dChiamp commented Feb 7, 2025

hey @rsm0128 i'd like to add a feature to encode svgs on the server so we can render them from the CMS using something like this:

https://stackoverflow.com/questions/76152412/how-to-transform-an-external-svg-to-a-vue3-component/78787495#78787495

i got that working here:
https://github.com/funkhaus/components/blob/updates/app/components/svg-loader.vue

You can use this endpoint to see how the SVGs are being returned in acf here:
https://jhpiego.flywheelsites.com/wp-json/fuxt/v1/post?uri=about-us&fields=acf

in partners acf field this is what is being returned:

"acf": {
"image_and_text": [],
"partners": [
{
"id": 202,
"src": "https://jhpiego.flywheelsites.com/wp-content/uploads/2025/02/Pabst.svg",
"width": 0,
"height": 0,
"alt": "",
"caption": "",
"title": "Pabst",
"description": "",
"mime_type": {},
"html": "<img src=\"https://jhpiego.flywheelsites.com/wp-content/uploads/2025/02/Pabst.svg\" class=\"attachment-full size-full\" alt=\"\" decoding=\"async\" loading=\"lazy\" />",
"srcset": "[https://jhpiego.flywheelsites.com/wp-content/uploads/2025/02/Pabst.svg 0w](https://jhpiego.flywheelsites.com/wp-content/uploads/2025/02/Pabst.svg%200w)",
"sizes": "0px",
"meta": {
"filesize": 20632
},
"acf": [],
"type": "image"
},

i think i field like encodedContent or something like that is what we want to return the svg like so:
PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMjQgMjQiPjxwYXRoIGQ9Ik0xMS45OSAyQzYuNDcgMiAyIDYuNDggMiAxMnM0LjQ3IDEwIDkuOTkgMTBDMTcuNTIgMjIgMjIgMTcuNTIgMjIgMTJTMTcuNTIgMiAxMS45OSAyem0zLjMgMTQuNzFMMTEgMTIuNDFWN2gydjQuNTlsMy43MSAzLjcxbC0xLjQyIDEuNDF6IiBmaWxsPSJjdXJyZW50Q29sb3IiPjwvcGF0aD48L3N2Zz4=

then it should all work.

Let me know if you have any questions or other ideas, thanks!

@rsm0128 rsm0128 linked a pull request Feb 12, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants