For those interested, to get an additional file_path variable which returns ‘/images/uploads/theimage.jpg’ I modified the array at line 1223 in ext.mh_file_ext.php to look like this:
$var = array(
'count' => $count+1,
'total_results' => $total_results,
'file_name' => $file,
'file_path' => "/".str_replace($PREFS->ini('site_url'), "", $file_field['url']).$file,
'file_url' => $FNS->remove_double_slashes($file_field['url'].'/'.$file),
'file'.$this->thumb_suffix.'_name' => $thumb,
'file'.$this->thumb_suffix.'_url' => $thumb_url
);
Here’s the code. “{feature_thumb}” returns the file name for some of the results and the path+file_name for others. Thanks for your help.
-Shawn
{exp:weblog:entries weblog="advice" limit="20" offset="1" orderby="date" disable="member_data|pagination|trackbacks" status="open" dynamic="off"}
<li>
{if feature_thumb}
<a href="http://{entry_id_path=article}{url_title}">{feature_thumb}</a>
{if:else}
<a href="http://{entry_id_path=article}{url_title}">/assets/images/shared/feature_thumb.jpg</a>
{/if}
<div>
<h3><a href="http://{entry_id_path=">{title}</a></h3>
{entry_date format="%F %d, %Y"}
</div>
</li>
{/exp:weblog:entries}
This may be a weird parsing order issue. Out of curiosity, what happens if you split the if into two simple conditionals?
{if feature_thumb}
<a href="http://{entry_id_path=article}{url_title}">{feature_thumb}</a>
{/if}
{if feature_thumb == ""}
<a href="http://{entry_id_path=article}{url_title}">/assets/images/shared/feature_thumb.jpg</a>
{/if}
Not sure if this can be implemented but it would be awesome if you could have an option of having a text field for each upload box to put in a caption when using the multiple images option. That way each image in an entry can have it’s own caption. Maybe when it saves the data to the exp_weblog_data table it could look like this:
file1.jpg|Caption for file1.jpg
file2.jpg|Caption for file2.jpg
file3.jpg|Caption for file3.jpg
file4.jpg|Caption for file4.jpg
Alright, I successfully hacked this extension to include captions. The caption field only shows up for the File Fields that have the Multiple Uploads enabled. To use it in the template, you use the variable {caption}. If the caption is not set then it will spit out the file name. It doesn’t add any extra fields in the exp_weblog_fields or exp_weblog_data tables, it just appends the caption to each file like I posted above.
It’s probably a crap job but it works heh. Since I’m not too confident in the code I’m not going to post it publicly. If anyone wants it, just send me a PM.
Cody, I actually did this a while ago for a project, along with descriptions. However when it came to thumbs/descriptions/captions the | delimiter got a little craptacular, so I changed the storage to serialized arrays. Also, watch out how you use the fill the repeating blocks, I noticed LG’s regular method would cause blank entries on items with the same file name or, in your case, caption as well. I planned on releasing the update I had made, but I haven’t had time to clean it up as it was for a site that I just needed this specific functionality for and didn’t care for some of the pieces LG included originally.
LG? I’m thinking you got the author of this extension confused hehe. Mark Huot made this extension, not Levi.
Also, I’m not sure what you mean by repeating blocks? There won’t be any duplicate file names since you can’t have duplicate files on your server. Also the way I’m doing it, having the same caption for more than one picture works just fine. I like the idea of putting them into serialized arrays though heh. Anyways, this is working just fine for my own purposes 😊.
Ah, yeah- Mark and Levi have become slightly interchangable in my mind I suppose. Both great contributors! Sorry for the mix up. Anyway- I just grabbed the file and cleaned it up a bit if you wanted to take a look. I was also supporting .mov and .wav uplaods and using custom thumbnails for each of them, and getting video resolution sizes with the php getid3 lib. As you can see on lines 1445/1447 you can either not use those file types or change the file paths if you like. I’m sure there’s other things wrong with it, but I made it quickly for a specific project and purpose. Hopefully I’m not breaching any copyrights by Mark (?)
Enjoy.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.