So, it's my first time using Orchard and liquid so bare with me on this one! I've not much experience in either really, but I'm getting to grips with it (slowly), except this one has me scratching my head.
I'm trying to loop through a gallery, and include the alt text (using Orchards .MediaTexts) for each image within the for loop with no success.
I've tried assigning the alt text inside the loop with no joy, like...
{% assign altText = Model.ContentItem.Content.Blog.Carousel.MediaTexts %}
SO was wondering where I am going wrong. Is there a way in liquid to do a "For A in Y AND for B in Z"? unsure...
Any help greatly appreciated.
Here is my code...
{% assign carousel = Model.ContentItem.Content.Blog.Carousel %}
{% for image in carousel.Paths %}
<div class="thumbnail">
<a href="/media/{{image}}" data-caption="{{ WOULD LIKE THE ALT TEXT HERE }}" data-fancybox="main-gallery">
{{ image | asset_url | img_tag: alt: WOULD LIKE THE ALT TEXT HERE }}
</a>
</div>
{% endfor %}
Related
I am using Jekyll and trying to display some code in a post, but I can't figure out why the code wont display on different lines. From what I understand it's supposed to word wrap with the way I have it set up.
I have this in my config file:
markdown: kramdown
highlighter: rouge
kramdown:
input: GFM
My code is:
{% highlight javascript linenos %}
var text = prompt("Write your text.");
alert("You have written " + text.length + " characters, you have " + (140 - text.length) + " characters remaining.");
{% endhighlight %}
It displays like:
Also on mobile it just removes all of the styling and displays like a regular <code> tag.
You can view the page here: https://alignthem.com/07/03/2022/javascript-length-and-concatenate/
Adding:
white-space: pre-wrap;
to .highlight pre worked
I have the following simple table with Livewire:
#foreach ($sms_lists as $sms_list)
<x-table.row>
#if($listForEdit && $listForEdit['id'] == $sms_list->id)
<x-table.cell>
<span wire:click="firstAction">FIRST</span>
<span wire:click="secondAction">SECOND</span>
</x-table.cell>
#else
<x-table.cell>
<span wire:click="thirdAction">THIRD</span>
<span wire:click="fourthAction">FOURTH</span>
</x-table.cell>
#endif
</x-table.row>
#endforeach
NOTE: For the problem described below I have tested in this environment mostly with button, but also with a and div. I have made it span just for clarity.
The SECOND item always performs fourthAction.
If I comment out the FOURTH item, SECOND starts working.
If I change to the fourth item just to <span></span> or ANY element - SECOND stops working.
It works only if the #else has only one span. I see the icon and text of SECOND but somehow all attributes are from FOURTH... including all events and onclicks etc.
PS: Adding an ID to the FOURTH makes it stay persistently and never hide, even if it's whole block is hidden in the #else, it just stays between the FIRST and SECOND...
You've to add wire:key="$loop->index" to the row for livewire to identify the rows.
Is it possible to hide an image with a specific alt tag?
I'm using shopify and have a 360 gif that I want to use on mouseover on categorie (collection) pages, but I don't want the thumbnail on the product page. You can give images alt text, wondering if I use the alt tag "gif" on those images, if there is a way to hide them from appearing as a thumbnail.
Thanks!
Just use alt attribute to check whether it equal to gif. If so, skip them.
{%- for media in product.media -%}
{%- unless media.alt == "gif" -%}
...
{%- endunless -%}
{%- endfor -%}
I have the following loop which displays images in a gallery:
<a href="#" v-for="(file, index) in files" v-bind:key="file.id" #click="file.selected = !file.selected">
<img :src="file.url" />
<span>{{file.name}}</span>
<i v-show="file.selected" class="fa fa-check-square"></i>
</a>
I would like to be able to select any image by clicking on it.
But nothing happens when I click on the image.
I did it the way I would do it in AngularJs - I modify the item within the loop.
I was expecting that:
- the view (inside of the loop) will be updated
- the change of the item will be taken over into the data array (files)
Ok, that was easy - it did not work the way I wanted, because I did not add a key "selected" to my initial data array.
In AnguarJS this would not matter - the key would just be added, but here the element is not known / watched if it does not exist from the beginning.
i was able to display repuations in a tab but i want an image to represent the reputation number.
<i class="fa fa-star-half-o"></i> {{$artists->reputations}} </a></li>
For instance if the reputation is 5 i want an image to repeat 5 times,
if the reputation is 1 i want the image to repeat once and so on.
the image is located in my 'assets/images' folder
i tired doing something like this below
<?php
$j = artists->reputations;
#for($j=1;$j<=5;$j++)
<i class="fa fa-star-half-o"></i> <img src="assets/images/star.png" style="height:60px;"></a></li>
;?>
You are overwriting $j in your loop condition.
So you always get 5 images.
it should be looking like this if you only want 3 stars if $artists->reputations = 3.
<?php
$j = artists->reputations;
for($i=1;$i<=$j;$i++){
<i class="fa fa-star-half-o"></i> <img src="assets/images/star.png"style="height:60px;"></a></li>
}
?>