Created
March 10, 2021 14:46
-
-
Save mustardBees/a30670fddf165a3d43236066057366f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: List Image URLs From Attachment IDs | |
Plugin URI: https://www.philwylie.co.uk/ | |
Description: Generate list of original attachment file URLs from a list of attachment IDs. Download using something like Tab Save - https://link.from.pw/3veCu6q | |
Version: 1.0.0 | |
Author: Phil Wylie | |
Author URI: https://www.philwylie.co.uk/ | |
License: GPL2 | |
*/ | |
/** | |
* Class PW_List_Attachments. | |
*/ | |
class PW_List_Attachments { | |
/** | |
* Initialize the plugin by hooking into WordPress. | |
*/ | |
public function __construct() { | |
add_action( 'init', array( $this, 'generate_list' ) ); | |
} | |
/** | |
* Hit example.com/?export-attachments. Use at your own risk. Backup first! | |
*/ | |
public function generate_list() { | |
if ( ! isset( $_GET['export-attachments'] ) ) { | |
return; | |
} | |
$attachment_ids = array( | |
1941,1942,1940,2058,1958,1957,1956,2059,1955,1970,2064,2063,2062,1974,1975,1976,1977,1978,1979,1980,1981,2066,1985,2040,2041,2042,2044,2037,2038,1989,1992,1995,1996,2017,2018,2019,2020,2021,1990,1999,1997,1993,1989,1991,1994,1737,1992,2002,2003,2012,2013,2014,2015,2016,2033,2034,2035,2036,2010,2009,2006,2008,2007,2005,2024,2025,2026,2027,2028,2029,2030,2031,2032 | |
); | |
foreach ( $attachment_ids as $attachment_id ) { | |
echo wp_get_attachment_url( $attachment_id ) . '<br>'; | |
} | |
exit; | |
} | |
} | |
new PW_List_Attachments(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment