WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Random / Rotating Ads V2] Image upload option Datafeedr ads (20 posts)

  1. Rhand
    Member
    Posted 4 years ago #

    Somebody mentioned this random datafeedr ads plugin used to have an option to upload images instead of adding text + an image link. Is that so? If not, is there a ad rotator plugin that has the same functionality plus and image uploader?

    http://wordpress.org/extend/plugins/datafeedr-ads/

  2. Rhand
    Member
    Posted 4 years ago #

    Support forum @ http://wphelpcenter.com/ seems impossible to find. Maybe they only offer commercial services. Anyone?

  3. Rhand
    Member
    Posted 4 years ago #

    Found forum, but seems to be for commercial users: http://www.datafeedr.com/forums/index.php

  4. news reporter
    Member
    Posted 4 years ago #

    what about the plug-in kadom ads management? i'm liking that. i place an ad by uploading the image

  5. news reporter
    Member
    Posted 4 years ago #

    you can look at http://www.lewiscountysirens.com to see what mine looks like. i haven't got them to rotate yet, but then, i'm pretty new at this

  6. Rhand
    Member
    Posted 4 years ago #

    Thanks news reporter. Will have a look asap.

  7. Rhand
    Member
    Posted 4 years ago #

    Removed this post as it was mentioned twice..

  8. Rhand
    Member
    Posted 4 years ago #

    Added this code for an image upload field, but it does not work yet:

    <?php
    	function my_admin_scripts() { // load necessary script including new script
    	wp_enqueue_script('media-upload');
    	wp_enqueue_script('thickbox');
    	wp_register_script('my-upload', WP_PLUGIN_URL .'/my-script.js', array('jquery','media-upload','thickbox'));
    	wp_enqueue_script('my-upload');
    	}
    
    	function my_admin_styles() {
    	wp_enqueue_style('thickbox');
    	}
    
    	if (isset($_GET['page']) && $_GET['page'] == 'datafeedr-ads') {
    	add_action('admin_print_scripts', 'my_admin_scripts'); // run javascripts in html header
    	add_action('admin_print_styles', 'my_admin_styles'); // add your own css styles
    
    	}
    
    	?>
    
    				<tr valign="top">
    				<th scope="row">Upload Image</th>
    				<td><label for="upload_image">
    				<input id="upload_image" type="text" size="36" name="upload_image" value="" />
    				<input id="upload_image_button" type="button" value="Upload Image" />
    				<br />Enter an URL or upload an image for the banner.
    				</label></td>
    				</tr>
  9. Rhand
    Member
    Posted 4 years ago #

    Maybe the script has to be adjusted as it is part of another plugin now with its own form. Here is the custo script that should be loaded:

    jQuery(document).ready(function() {
    
    jQuery('#upload_image_button').click(function() {
     formfield = jQuery('#upload_image').attr('name');
     tb_show('', 'media-upload.php?type=image&TB_iframe=true');
     return false;
    });
    
    window.send_to_editor = function(html) {
     imgurl = jQuery('img',html).attr('src');
     jQuery('#upload_image').val(imgurl);
     tb_remove();
    }
    
    });
  10. Rhand
    Member
    Posted 4 years ago #

    Complete plugin code here: http://wordpress.pastebin.com/yprywP7J

  11. Rhand
    Member
    Posted 4 years ago #

    Added script to top which did load thickbox and I did get a pop-up thanks to mordot at #wordpress (IRC) . Now I see the added my-script.js is not loaded so I think:

    wp_register_script('my-upload', WP_PLUGIN_URL.'/my-script.js', array('jquery','media-upload','thickbox'));
    wp_enqueue_script('my-upload');

    is not loaded. Any ideas why?
    The media-upload does not load either. The latter I suspect to be a js conflict..

    See http://wordpress.pastebin.com/xF0xs9mL
    `

  12. Rhand
    Member
    Posted 4 years ago #

    Well wp_register path was off. This path:

    wp_register_script('my-upload', WP_PLUGIN_URL.'/datafeedr-ads/my-script.js', array('jquery','media-upload','thickbox'));

    works better. Only now it shows two thickboxes under each other. One empty and the other with the media uploader..

  13. Rhand
    Member
    Posted 4 years ago #

    Hmmm TB_Title is loaded twice and TB_ajaxContent is there for no reason. How can I get rid of those?

  14. Rhand
    Member
    Posted 4 years ago #

    Well I removed class="thickbox" in added upload field which apparently loaded styled thickboxes twice. Looking better yet again :-) Updated code: http://wordpress.pastebin.com/7QZ8ucBM

  15. Rhand
    Member
    Posted 4 years ago #

    Next q, how do I get the the link to the uploaded url to be added to the add box?

    code: http://wordpress.pastebin.com/7QZ8ucBM

  16. Rhand
    Member
    Posted 4 years ago #

    Well I do get the url, but I would like the javascript to wrap the url in an <img src="" /> tag as well. How would I do that?

  17. Rhand
    Member
    Posted 4 years ago #

    jQuery(document).ready(function() {
    
    jQuery('#upload_image_button').click(function() {
     formfield = jQuery('#upload_image').attr('name');
     tb_show('','media-upload.php?type=image&TB_iframe=true');
     return false;
    });
    // send url back to plugin editor
    
    window.send_to_editor = function(html) {
     imgurl = jQuery('img',html).attr('src');
     jQuery('#dfrads_textarea').val(imgurl);
     tb_remove();
    }
    
    });

    did the trick to load url inside iamge tag in box. Just had to adjust the JQuery value/class ..

  18. Rhand
    Member
    Posted 4 years ago #

    Changed the class in the custom JQuery so url is loaded in proper field. Only need it to load to the proper ad box.

  19. Rhand
    Member
    Posted 4 years ago #

    Added jscript to pastebin as well: http://wordpress.pastebin.com/S99tedER . PHP script is still @ http://wordpress.pastebin.com/S99tedER . Main issue still remains the position of the image upload field. It is show below all ad. I should be underneath each add box. But now when a new one is added there is only one upload box and it is below all shown add boxes.

  20. Rhand
    Member
    Posted 4 years ago #

    New JavaScript version: http://wordpress.pastebin.com/Q58Bh1AL Had to change id to class to load link into text area. Now I need to wrap it all in an image tag AND to make sure the url goes into the right text area add box..

  21. husar
    Member
    Posted 4 years ago #

    What if I wanted to allow them to upload something other than an image file? For example I have this working to a point and allow users to upload a GPX file in my plugin. All I had to do was remove the ‘type=image’ from the tb_show and WordPress will handle what file types can be uploaded for me.

    tb_show(”, ‘media-upload.php?TB_iframe=true’)

    Launching the window and uploading the file is not the problem. It is getting the form text field to be populated with the GFX URL. I know I would have to change these lines….

    imgurl = $(‘img’,html).attr(’src’);
    jQuery(‘#upload_image’).val(imgurl);

    … to get them to look for something other than ‘img’ and ’src’ But what?

    Cheers.

Topic Closed

This topic has been closed to new replies.

About this Topic