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

Show image thumbnail near to ElFinderType widget #527

Open
frizquierdo opened this issue Mar 20, 2024 · 2 comments
Open

Show image thumbnail near to ElFinderType widget #527

frizquierdo opened this issue Mar 20, 2024 · 2 comments

Comments

@frizquierdo
Copy link

Hi, I'm starting to use this bundle, it's wonderful.

Short description of what this feature will allow to do:
It's possible show an image thumbnail near to ElFinderType widget after select and immage from Elfinder browser?

Example of how to use this feature
something like this but much more refined and the associated event handler:

% block elfinder_widget %}
    {% if value is not empty %}
        <div class="content d-flex align-items-stretch w-100">
            <div class="d-flex w-100">
                <div class="d-flex align-items-center w-100">
                    <img class="img-thumbnail " src="{{ value }}" width="100px;" height="100px;"/>
                </div>
            </div>
        </div>
    {% endif %}

  -- rest of widget definition ----
    <input type="text" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %} data-type="elfinder-input-field" />
    {% if enable and instance is defined %}
        <script type="text/javascript" charset="utf-8">
            live('click', '[data-type="elfinder-input-field"][id="{{ id }}"]', function (event) {
                console.warn('Test');
                var childWin = window.open("{{path('elfinder', {'instance': instance, 'homeFolder': homeFolder })}}?id={{ id }}", "popupWindow", "height=450, width=900");
            });
            function live (eventType, elementQuerySelector, cb) {
                document.addEventListener(eventType, function (event) {
                    var qs = document.querySelectorAll(elementQuerySelector);
                    if (qs) {
                        var el = event.target, index = -1;
                        while (el && ((index = Array.prototype.indexOf.call(qs, el)) === -1)) {
                            el = el.parentElement;
                        }
                        if (index > -1) {
                            cb.call(el, event);
                        }
                    }
                })
            }
            function setValue(value, element_id) {
                document.querySelector('[data-type="elfinder-input-field"]' + (element_id ? '[id="'+ element_id +'"]': '')).value = value;
            }
        </script>
    {% endif %}
{% endblock %}

The idea is to get something like this:
thumb preview

@helios-ag
Copy link
Owner

hi @frizquierdo
This bundle only provides basic functionality for frontend part, you can try to intercept events between windows (parent and elfinder's)(or share state between them), but this needs to be researched

@frizquierdo
Copy link
Author

frizquierdo commented Mar 21, 2024

hi @frizquierdo This bundle only provides basic functionality for frontend part, you can try to intercept events between windows (parent and elfinder's)(or share state between them), but this needs to be researched

Thank you for yours tips. exactly, the solution was in "share" from getFileCallback(), in elfinder/simple.html.twig, a selected file url with the window.owner that open elfinder browser ; and customize elfinder_widget.html.twig and add necessaries listeners to the new view elements to open elfinder browser and remove selected image.

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

No branches or pull requests

2 participants