I’m creating a blog and want to use the new features in EE 2.2, but the file field tag didn’t give me the options of showing the title or caption of an image in a channel entry. So i decided to try to create a hack for it. I know changing the core files isn’t a smart way in the long run, but it does what I want for now.
By adding this piece of code on line 271 between “$file_info[‘fullname’]...” and “return $file_info;” in the ft.file.php:
$file_info['fullname'] = $file_info['filename'] . '.' . $file_info['extension'];
$query = $this->EE->db->query("SELECT file_id, title, caption FROM exp_files WHERE file_name = '" . $file_info['fullname'] . "' LIMIT 1");
if ($query->num_rows() > 0)
{
foreach($query->result_array() as $row)
{
$file_info['id'] = $row['file_id'];
$file_info['title'] = $row['title'];
$file_info['caption'] = $row['caption'];
}
}..you’re able to use {id} {title} {caption} and {fullname} in a tagpair from an filefield.
Example (used inside the channel entries tag):
{my_img}
{path}{fullname}
ID: {id}
Filename: {fullname}
Title: {title}
Caption: {caption}
{/my_img}Would love to get any opinions or suggestions on this hack.