<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: Can&#039;t hook wp_insert_attachment</title>
		<link>https://legacy.forums.gravityhelp.com/topic/cant-hook-wp_insert_attachment</link>
		<description>Gravity Support Forums Topic: Can&#039;t hook wp_insert_attachment</description>
		<language>en-US</language>
		<pubDate>Sat, 04 Apr 2026 14:15:18 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/cant-hook-wp_insert_attachment" rel="self" type="application/rss+xml" />

		<item>
			<title>David Smith on "Can&#039;t hook wp_insert_attachment"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/cant-hook-wp_insert_attachment#post-37457</link>
			<pubDate>Mon, 10 Oct 2011 12:11:48 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">37457@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Kubante,&#60;/p&#62;
&#60;p&#62;The wp_insert_attachment() function does not appear to contain any filter titled &#34;wp_insert_attachment&#34;. I do see two actions that might of use to you; however, they are called after the attachment has already been inserted/updated. &#60;a href=&#34;http://grab.by/b2ew&#34; rel=&#34;nofollow&#34;&#62;http://grab.by/b2ew&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Using the &#34;add_attachment&#34; hook you could call your plugins custom functionality, post process the image and then &#34;update&#34; the attachment by sending the updated attachment object back to the wp_insert_attachment function.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>kubante on "Can&#039;t hook wp_insert_attachment"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/cant-hook-wp_insert_attachment#post-37192</link>
			<pubDate>Wed, 05 Oct 2011 20:59:52 +0000</pubDate>
			<dc:creator>kubante</dc:creator>
			<guid isPermaLink="false">37192@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hello,&#60;/p&#62;
&#60;p&#62;I am trying to hook the wp_insert_attachment function of wordpress,&#60;br /&#62;
because I would like to preprocess the file upload from gravityforms.&#60;/p&#62;
&#60;p&#62;in the gravityforms function media_handle_upload I noticed the call to&#60;br /&#62;
wp_insert_attachment like this:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;// Save the data
$id = wp_insert_attachment($attachment, $file, $post_id);
if ( !is_wp_error($id) ) {
    wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I did the following in my plugin:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;public function __construct() {
    add_filter( &#38;#39;wp_insert_attachment&#38;#39;, array( $this, &#38;#39;filter_insert&#38;#39; ), 1, 3 );
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;and the filter_insert function looks like this:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;public function filter_insert( $attachment, $file, $id){
exit;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;The result is, that the filter_insert function is not called...&#60;/p&#62;
&#60;p&#62;best&#60;/p&#62;
&#60;p&#62;regards&#60;/p&#62;
&#60;p&#62;kubante
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
