Forum Replies Created

Viewing 15 replies - 31 through 45 (of 186 total)
  • Thread Starter marcnyc

    (@marcnyc)

    Ok. I’ve been reading for hours but cannot figure out why I keep getting ” ERROR: Specified file failed upload test.” when I try this simple 20-line example on its own…. What am I doing wrong please?

    <form method="post" enctype='multipart/form-data'>
    <input type="file" id="file_to_upload" name="dlkimage1" />
    <?php
    require($_SERVER['DOCUMENT_ROOT'].'/wp/wp-load.php');
    require_once( ABSPATH.'wp-admin/includes/image.php' );
    
    if ( isset($_FILES["dlkimage1"]) && !empty($_FILES["dlkimage1"]["tmp_name"]) ) {
    	$image_id = media_handle_upload($_FILES["dlkimage1"]["tmp_name"],0);
    	if ( is_wp_error($image_id) )
    		echo 'ERROR: ' . $image_id->get_error_message();
    	else
    		echo $image_id;
    }
    
    ?>
    <button class="button" id="updatepreview" type="submit" />Update Preview</button>
    </form>
    • This reply was modified 4 years, 9 months ago by marcnyc.
    Thread Starter marcnyc

    (@marcnyc)

    ah I see… thanks for clarifying…
    right then I would need media_handle_upload…
    so, does media_handle_upload do everything I try to do with my function? uploading, creating database post, metadata and dependencies?

    Thread Starter marcnyc

    (@marcnyc)

    I shall read about it… so should I use sideload or media_handle_upload? I don’t understand the difference

    Thread Starter marcnyc

    (@marcnyc)

    I did not know about sideload. Does sideload handle upload as well as metadata and other DB dependencies?

    The manual says sideload “Downloads an image”, while I’m trying to upload images.

    I’ll look at wp_basename

    Yes I did start a session

    Thread Starter marcnyc

    (@marcnyc)

    Hey everyone, I wanted to post a correction to my code…

    <?php
    add_filter('postie_subject', 'my_postie_subject');
    
    function my_postie_subject($subject) {
    	// match the first four characters from the subject (works with Gmail, other email clients might prepend "Fw:" or "Forward:" or something else) after making it all lowercase to match both "Fwd:" or "fwd:"
    	if ( substr(strtolower($subject), 0, 4) === 'fwd:' ) {
    		$subject = substr($subject, 4); // remove first 4 characters from subject
    		$subject = trim($subject); // remove space at the beginning of subject line (because usually the subject of a forwarded email will be "Fwd: Category: Subject")
    	}
    	return $subject;
    }
    ?>

    Initially I had the return $subject; line in side the if statement which broke my system because whenever the email was NOT being forwarded it now lost its subject, so that line needs to be last so the subject is returned even if the email is not forwarded.
    Hope that helps

    Thread Starter marcnyc

    (@marcnyc)

    I have done all of this.
    The problem is that I cannot replicate the 500/503 errors, they just happen intermittedly

    Thread Starter marcnyc

    (@marcnyc)

    Thanks for that. I read it through. The problem is the article refers to a persistent error whereas in my case it happens every once in a while (but too over, like once a day or more) and then 30 min later the site is fine and I can’t trouble shoot that by removing plugins because I don’t know when it will happen and even if it happens removing plugins wouldn’t tell me if the server load just diminished or if it was removing the plugins that fixed it.
    There must be a way to find out WHICH pluging or script is causing it and how to address it, no?

    Thread Starter marcnyc

    (@marcnyc)

    Thank you for giving us this feature.

    Your filter does work, and so does my function, except for a small typo (I wrote strlolower, instead of strtolower). So for those who might stumble on this post looking to do the same, here is the corrected and tested function:

    I wanted to report back that your filter works and my function does too, with the exception of a small typo (I wrote strlolower, instead of strtolower), so for those who might stumble on this post, the correct function for the filterPostie.php file is:

    
    <?php
    add_filter('postie_subject', 'my_postie_subject');
    
    function my_postie_subject($subject) {
       // match the first four characters from the subject (works with Gmail, other email clients might prepend "Fw:" or "Forward:" or something else) after making it all lowercase to match both "Fwd:" or "fwd:"
       if ( substr(strtolower($subject), 0, 4) === 'fwd:' ) {
        $subject = substr($subject, 4); // remove first 4 characters from subject
        $subject = trim($subject); // remove space at the beginning of subject line (because usually the subject of a forwarded email will be "Fwd: Category: Subject")
        return $subject;
       }
    }
    ?>
    • This reply was modified 4 years, 9 months ago by marcnyc.
    Thread Starter marcnyc

    (@marcnyc)

    Sorry if I wasn’t clear.
    I have all the functions to do the things you describe and once I have both the post and its images inserted into the DB I need to update the post’s contents with what will be the HTML output.
    When doing so I use wp_get_attachment_image() which creates the <img... tag but how do I create the <figure... tag that I see in the posts that WP creates (see below)? Is there a function to create the <figure… tag?

    <div class="wp-block-image">
    <figure class="alignleft size-large is-resized"><img
    src="https://www.x.com/wp/wp-content/uploads/2020/05/y-1.jpg"
    alt="" class="wp-image-18233" width="499" height="299"
    srcset="https://www.x.com/wp/wp-content/uploads/2020/05/y-1.jpg 555w, https://www.x.com/wp/wp-content/uploads/2020/05/y-1-300x179.jpg 300w, https://www.x.com/wp/wp-content/uploads/2020/05/y-1-150x90.jpg 150w"
    sizes="(max-width: 499px) 100vw, 499px" /></figure></div>
    Thread Starter marcnyc

    (@marcnyc)

    Thank you for taking my feature request to heart.
    I’ve upgraded to the new postie just now but I don’t see the option. Is it in the backend or is it something I need to hard-code into the plugin?
    If so where would I put and how do I ensure I don’t loose that when I upgrade to the latest Postie?

    Thread Starter marcnyc

    (@marcnyc)

    I found (in the theme) the settings to prevent the generation of all those extra thumbnails and I will ask if there is a way to remove unwanted/unused ones.
    Thanks for your help

    Thread Starter marcnyc

    (@marcnyc)

    Hello @joyously
    thank you for all your help and patience throughout.
    After lots of reading I was able to create everything that I wanted to do.
    I have a function that adds my post to the database and then uploads & resizes the image attachments and creates the metadata in the database so all the backend is taken care of.
    I also found the wp_get_attachment_image() image so I can call that image for the HTML output.
    Now the very last step I’m trying to figure out is: how to create the <figure> tag. Is there a WP function for that or do I need to enter it manually into my post contents? I searched the reference manual but can’t find anything with “figure”.
    Thank you

    • This reply was modified 4 years, 9 months ago by marcnyc.
    Thread Starter marcnyc

    (@marcnyc)

    Does anyone know how I can speed up being approved as a moderator? it’s taking weeks and my translation is sitting there, unable to be used:

    https://profiles.www.ads-software.com/marcnyc/#content-translations

    Thread Starter marcnyc

    (@marcnyc)

    just curious, any hope this might be implemented in a future version? is there an “official” way to submit a feature request for this?

    Thread Starter marcnyc

    (@marcnyc)

    I am using the Newspaper X theme but I only just installed it 2 weeks ago so not a lot would break.
    Is there a way I can set that limit so that from now on the future posts will only have 2-3 images instead of 25? Then I can check the posts from the last 2 weeks and adjust

Viewing 15 replies - 31 through 45 (of 186 total)