Full disclosure: I am a non-developer designer so please take my limited programming knowledge into account if you attempt to assist!
Goal: Add alt text to images
What I’ve done so far: added a column img_alt_text that I would like to attach to the column event_img_lg. Should this be done in a pod template? helper? WP theme template? More importantly, how?
I haven’t been able to modify this to work since I pretty much don’t understand the PHP bits.
I was a little surprised not to find more on this in forums et al and hope that means it’s such a simple and obvious fix I should have figured it out on my own. Thank you, in advance.
Unfortunately, if you’re going to be using Pods, you need a basic understanding of PHP or you need to make friends with a programmer who can help you.
The easiest way to describe this is to put the code into your Pods page. Images get stored in an array, so using Pods templates necessitates the use of a helper, and that’s just going to add to the complexity.
Let’s assume your pod is called ‘my_pod’ and both of those columns are in there.
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
$Record=newPod('my_pod');// Define a new instance of my_pod
$Record->findRecords('t.id DESC',-1);// Load all the records in my_pod into memory
while($Record->fetchRecord()):// Loop through those records one by one
if($Record->get_field('event_img_lg.ID')):// If there is no image, skip to endif
$img_detail=wp_get_attachment_image_src($Record->get_field('event_img_lg.ID'),'large');// WordPress function to prepare the image for display