• Resolved alonagomez

    (@alonagomez)


    For the Image field, is it possible to show it as a button? Then when the button is clicked, it will open the image in full size.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author WPLake

    (@wplakeorg)

    Hi @alonagomez

    Yes, it’s possible.
    To do so, “Add New” View item, assign the Image field, Save.
    Then copy the ‘Template Preview’ content into the ‘Custom Template’, modify the image markup as per my example below, to output a link instead of the image.

    {% if image.value %}
    	<a href='{{ image.value }}'>
    	    Full size
    	</a>
    {% endif %}

    You can now add the shortcode to your page, and come back to the View and add CSS in the ‘CSS & JS’ tab to style your button.

    Thread Starter alonagomez

    (@alonagomez)

    Thanks it worked. I created a button with padding and background. I have a problem on the CSS for the link color because the default value is “a”. How to customize the “a” name because it is conflict with the website link if I change it to color white?

    https://pasteboard.co/VtwTU7VLQWZV.png

    • This reply was modified 1 year ago by alonagomez.
    Plugin Author WPLake

    (@wplakeorg)

    Hi@alonagomez

    You could try restricting the style to the specific button text, see below for an example. Paste it into your Views CSS & JS Tab in the CSS Code field.

    #view .views-button a {
    color: #ffffff;
    }
    

    You would also need to include a class for your template element.

    {% if image.value %}
        <div class="views-button">
    	    <a href='{{ image.value }}'>
    	        Full size
    	    </a>
        </div>
    {% endif %}
    Thread Starter alonagomez

    (@alonagomez)

    Thanks it worked.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display Image as Button’ is closed to new replies.