r1bryan
Forum Replies Created
-
Just figured it out yesterday. Your answer is correct. Funny my other site worked properly without filling in the field.
Thanks.
Forum: Plugins
In reply to: [Code Snippets] How to turn on/off a snippet from a pageThe plugin is called “code snippets” and when I click on it in the plugin admin page there appears checkboxes for running a particular set of code snippets. The code snippet I would like to mark as “on” or “off” from a different location than the admin page is shown below:
/* Automatically set the image Title, Alt-Text, Caption & Description upon upload
———————————————————————–*/add_action( ‘add_attachment’, ‘my_set_image_meta_upon_image_upload’ );
function my_set_image_meta_upon_image_upload( $post_ID ) {
// Check if uploaded file is an image, else do nothing
if ( wp_attachment_is_image( $post_ID ) ) {
//$my_image_title = get_post( $post_ID )->post_title;
//$filename = basename( get_attached_file( $doc_id ) );
$my_image_title = basename( get_attached_file($post_ID ) );
// Sanitize the title: remove hyphens, underscores & extra
// spaces:
$my_image_title = preg_replace( ‘%\s*[-_\s]+\s*%’, ‘ ‘,
$my_image_title );
$my_image_title = preg_replace( ‘/\.jpg$/’, ”,
$my_image_title );
// Sanitize the title: capitalize first letter of every word
// (other letters lower case):
$my_image_title = ucwords( strtolower( $my_image_title ) );
//
//remove begining – category
$x = strpos($my_image_title,”By “);
$x = $x + 3;
$my_image_title = substr($my_image_title,$x);
//remove date at end
$my_image_title = substr($my_image_title,0,-9);
//save title
$x = strpos($my_image_title,” For “);
$x = $x + 5;
$title = substr($my_image_title,$x);
//save name
$x = strpos($my_image_title,” For “);
$name = substr($my_image_title,0,$x);
// title + name
$my_image_title = $title . ” – ” . $name;
//
// Create an array with the image meta (Title, Caption,
// Description) to be updated
// Note: comment out the Excerpt/Caption or Content/Description
// lines if not needed
$my_image_meta = array(
// Specify the image (ID) to be updated
‘ID’ => $post_ID,
// Set image Title to sanitized title
‘post_title’ => $my_image_title,
//remove classification text from title
// Set image Caption (Excerpt) to sanitized title
‘post_excerpt’ => $my_image_title,
// Set image Description (Content) to sanitized title
‘post_content’ => $my_image_title,
);// Set the image Alt-Text
update_post_meta( $post_ID, ‘_wp_attachment_image_alt’,
$my_image_title );
// Set the image meta (e.g. Title, Excerpt, Content)
wp_update_post( $my_image_meta );
}
}Forum: Plugins
In reply to: [Media Sync] Possible different import directory?Yes, works perfectly. Thanks erolsk8 for the update – Just what I needed!
Forum: Plugins
In reply to: [Media Sync] Possible different import directory?Your code:
/wp-admin/upload.php?page=media-sync-page&scan_files=1&sub_dir=contestimages
worked for operating from contest images sub folder without affecting other parts of wordpress.
Thanks!
rbForum: Plugins
In reply to: [Media Sync] Possible different import directory?Tried adding the code to wp-content and did the trick however it messes with my website images so not workable. Would be nice to quickly browse to a directory like “Add to Server” plugin does, but not a deal breaker. Media Sync is almost perfect for my needs, thanks for the plugin @erolsk8.
Forum: Plugins
In reply to: [Media Sync] Spins endlesslyFound that for me when Object Cache is enabled in the W3 Total Cache Plugin, that causes the endless spin of import selected. I dont know anything about Object Cache but from the description it appears not to be very important. Disabled Object Cache and now Import is working. YES!
Forum: Plugins
In reply to: [Media Sync] Spins endlesslyImport selected spins endlessly. Tried disabling all my plugins that didn’t help. Changed my wp-config file to add set_time_limit(300), that didn’t help. Changed my php.ini file to max_execution_time 300. That didn’t help. Anything else I can try?
Just what I need if I can get it to work.
Thanks
Randy.