Saturday, May 21, 2016

WordPress get uploaded image path

To get the full path of an attachment use the following method.

<?php $path = get_attached_file( $attachment_id ); ?>


The above will give you full path of the file/attachment.

If you just want the filename and not path then use the following code.

<?php $filename_only = basename( get_attached_file( $attachment_id ) ); ?>

This will give you just the filename.

No comments:

Post a Comment

MS SQL : How to identify fragmentation in your indexes?

Almost all of us know what fragmentation in SQL indexes are and how it can affect the performance. For those who are new Index fragmentation...