Hi, I am wondering if you can add this to a child theme? Can you give this a try and report back with the outcome.
Thank you
Happy to give it a try.
I’m comfortable adding theme files to a child-theme but how would this work with a plugin file?
Hi, that is a good question. Check the following documentation. Let me know if it helps you or not.
Regards
Haha! Now we’re going full-circle. Thank you for pointing me to your comments about php tweaks but you’ll note I already referred to them above.
I note your comments but I can’t see how to apply these requirements as a filter in this case.
Kind regards,
Phil.
Hi, my apologies.
I have submitted a message to the developers to investigate further your request.
Thank you
No worries. Thanks very much – looking forward to resolving.
All the best,
Phil.
This is not going to be a very trivial change. It does require a bit of advanced coding knowledge.
The following filter basically lets you FULLY override whatever output the shortcode is going to output:
sdm_download_shortcode_output
So you have to use that filter to fully customize the output of that template. Write the full code for how you want the output to look like (you can copy most of the code from template 1 then modify what you want to). At this stage you can’t just add a couple of lines to make the changes you are after.
I am going to add a new filter that is just for the thumbnail. That will help you do the customization with less code. I will add the filter hooks in the next release.
That’s awesome. Thanks so much for filling this gap. I think we’ll find a lot of use for the new filter. I look forward to the next release.
Kind regards,
Phil.
Just following up your direction to “Write the full code for how you want the output to look “. I have achieved the required display by modifying the output as follows:
In file includes/templates/fancy2/sdm-fancy-2.php. from line 144 onwards:
$output = '';
$output .= '<div class="sdm_fancy2_item ' . $css_class . '">';
$output .= '<div class="sdm_fancy2_wrapper">';
$output .= '<div class="sdm_fancy2_download_item_top">';
// Next line modified to put url around image.
//$output .= '<div class="sdm_fancy2_download_thumbnail">' . $isset_download_thumbnail . '</div>';
$output .= '<div class="sdm_fancy2_download_thumbnail">' . '<a href="' . $download_url . ' target="' . $window_target . '">' . $isset_download_thumbnail . '</a></div>';
$output .= '</div>'; //End of .sdm_download_item_top
$output .= '<div class="sdm_fancy2_download_title">' . $item_title . '</div>';
So should this code now be moved into the filter in functions.php or does more code have to be copied across?
Hi @carryoncoding, the latest version has two new filters included in the code. Let us know if this works for you.
kind regards
Thanks for taking this forward – I’m sure it will make SDM even more useful than it already is!
Have you documented the new filters at all or can you point me to where I can see how to use them?
Thanks,
Phil.
Hi, you can use the above documentation link I shared to learn more about filters. The following are the two new filters added.
sdm_download_fancy_1_thumbnail
sdm_download_fancy_2_thumbnail
Kind regards
Very many thanks for all your help. I was able to take the work you shared and create the required appearance and function.
Here is the final version based upon your example and using knowledge gained from sdm-fancy-2.php
// SDM filter to make thumbnail clickable
add_filter('sdm_download_fancy_2_thumbnail', 'custom_fancy2_thumb_output', 10, 2);
function custom_fancy2_thumb_output($thumb_output, $args){
$download_id = $args['id'];
$download_thumb_url = get_post_meta($download_id, 'sdm_upload_thumbnail', true);
$thumb_output = '<a href="' . $homepage . '/?smd_process_download=1&download_id=' . $download_id . '" target="_blank">' . '<img src="' . $download_thumb_url . '" class="sdm_fancy2_thumb_image" />' . '</a>';
return $thumb_output;
}
Please note that I had to correct “get_post_meta($id as that needed to be $download_id. I also needed to change class=”sdm_download_thumbnail_image” into class=”sdm_fancy2_thumb_image”.
I noticed that $window_target wasn’t visible from within the filter code so had to hardwire the target=”_blank”. I’m sure this could be improved but it seems to work fine!
Thanks again.
Phil.