-
Notifications
You must be signed in to change notification settings - Fork 2
Single image src generation #9
Comments
hmmm... yeah I could probably add this 1 Just spit-balling here.. I'll probably make a new twig tag since this could help with my problem I'm running into with generating a picture element (see #4). At least one aspect of it - having different crop directions for picture element sources not a full picture element -
|
Alright @zomars I've thrown something together https://github.com/cdowdy/boltbetterthumbs/releases/tag/v1.3.1 have a play around with it let me know any issues you come across please! You'll need to use a different tag and config setup. # Config setup:
configName:
# all your modifications here
w: 300
h: 150
fit: 'crop-top-left' Template usage: {{ bthumb( record.image, 'configName' ) }} |
Will do! Thanks for the update! |
Hi, My output looks like this: So the Url breakes :-( MacOS: 10.12.3 regards, |
hmm @kutulus you seem to be doing everything right. If you open the image in a new tab does the image work or does it say "operation not permitted"? I changed somethings around earlier and I might have over looked the single image src generation so give me a bit and I'll test it out on my dev setup! Sorry about breaking things if I did haha ;) |
Hey cdowdy, |
ok.. that means there is a signature mismatch. Did you pre generate these images through the back end prime page? If you have a chance could you visit the back end files page (/bolt/extend/betterthumbs/files) and delete the image then try to use the image again in your template (unless you already have then don't haha). I thought I stomped out all these url encoding quirks earlier but chances are I didn't haha |
hmm I just tried on Apache and Nginx.. here is my single:
w: 200 Here is my index.twig template: <img src="{{ bthumb( record.image, 'single' ) }}" alt="placeholder alt text"> Are you using this in a background image by chance? |
Yes, I´m trying to set a background-image like this: `<style media="screen"> section.hero { background-image: url('{{ bthumb(record.image, 'single') }}'); } </style>` |
... tried with no result :-( |
@kutulus yeaaaah.... drats thats a problem haha.. the ampersands in the url inside a style tag cause problems....... if you apply the image directly to the section tag you can use single quotes... ie: <div style="background-image: url( '{{ bthumb( record.image, 'single' ) }}' ); width: 200; height: 200; ">
<p>hi</p>
</div> But that isn't a very good / maintainable solution... Give me a bit I'll see if I can "properly" fix it and allow usage inside a style tag.... My fault for not properly testing that out haha I apologize! |
ahhh, I see. – the workaround works, thanks for that. |
well.. I have a solution :) and I'll push a new release here in a few moments... I wrote these really complicated filter methods and decoded url's and all this and.... well I didn't even need to haha. I just used the twig raw tag. you can apply this fix too if you don't wanna wait on a new release to hit bolt's extension service.. Go into my extension ( add the {# test out for not found and single image right now #}
{% macro setImg( srcImg, sourceExists, notFoundImg ) %}
{% if sourceExists %}/img{{ srcImg|raw }}{% else %}
{{ notFoundImg }}{% endif %}
{% endmacro setImg %} |
fixes #9 adds a raw filter so images can be used in in page style tags
... seems to work fine! Tanks for your quick solution! |
I want to incorporate this extension to a current website I have but I'm using some pictures elements and some inline background-images with css.
It would be nice if I could generate a single image url without an img tag for me to use in other scenarios.
Thank you for making this extension and keep up the good work! 👍
The text was updated successfully, but these errors were encountered: