Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   New Versions, & Updating (http://forum.bytesforall.com/forumdisplay.php?f=12)
-   -   The code needed to customize location of header images (http://forum.bytesforall.com/showthread.php?t=19549)

geir Feb 3, 2013 07:08 PM

The code needed to customize location of header images
 
I have to agree with a lot of the arguments put forth by noel.odesk in the now closed thread Why I Hate Upgrading Atahualpa.
Now, php is not my native language, but from what I can see, these are the code changes needed to introduce a theme option for specifying the location of the header image files. This will allow the header images to be put in a directory that survives a theme upgrade. Incorporating these few lines of code into an otherwise excellent theme would make life a little bit easier for quite a few of the ATA users out there.

File: functions/bfa_theme_options.php
Code:

(...)
                        common today, so the images should be that wide or wider. The next common screen widths are 1440, 1600, 1680 and
                        1920 pixels. </li></ul>" . $header_image_text),

+    array(    "name" => "Header Images Directory",
+            "category" => "header-image",
+            "id" => "header_images_dir",
+            "std" => "images/header",
+            "type" => "text",
+            "info" => "Directory for header image(s), relative to Atahualpa theme directory. No leading or trailing slashes."),
+

    array(    "name" => "Rotate header images with Javascript?",
            "category" => "header-image",
            "id" => "header_image_javascript",
(...)

File: functions/bfa_get_options.php
Code:


(...)
                        "allow_debug",
                        "IEDocType",
+                      "header_images_dir",
                        "overlay_header_image"
                        );
(...)

File: functions/bfa_rotating_header_images.php
Code:

(...)
                ################### images in /images/header/ (on regular WordPress)

                $files = "";
-              $imgpath = get_template_directory() . '/images/header/';
-              $imgdir = $templateURI . '/images/header/';
+                if(isset($bfa_ata['header_images_dir'])) {
+                        $imgpath = get_template_directory() . '/' . $bfa_ata['header_images_dir'] . '/';
+                        $imgdir =  $templateURI . '/' . $bfa_ata['header_images_dir'] . '/';
+                } else {
+                        $imgpath = get_template_directory() . '/images/header/';
+                        $imgdir = $templateURI . '/images/header/';
+                }

                $dh  = opendir($imgpath);

                while (FALSE !== ($filename = readdir($dh))) {
(...)


juggledad Feb 4, 2013 10:02 AM

I spoke to Flynn and he thinks this will fly. I tested it and came up with a nice feature. If you use
'../../dirname' then you can put 'dirname' in the wp-contents folder and never worry that it might get removed during an update.

I'll be putting the code together along with the two 3.7.10 patches and giving it to Flynn for submission to WordPress.

Nice work, Ive been wanting to put something like this in pointing outside the theme directory, but by putting it in teh theme directory and using the '../../dirname' you can actually have the image directory outside the theme folder, the best of both worlds!!!

geir Feb 4, 2013 05:56 PM

Quote:

Originally Posted by juggledad (Post 96054)
I spoke to Flynn and he thinks this will fly. I tested it and came up with a nice feature. If you use
'../../dirname' then you can put 'dirname' in the wp-contents folder and never worry that it might get removed during an update.

Exactly. And I'm sure there are plugins out there (recommendations, anyone?) that let you control your media folder structure in such a way that those who want to avoid ftp altogether can point to a directory within their media library.

Quote:

I'll be putting the code together along with the two 3.7.10 patches and giving it to Flynn for submission to WordPress.
Sounds good.


All times are GMT -6. The time now is 10:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.